Skip to content

Commit

Permalink
Upgrade dependencies
Browse files Browse the repository at this point in the history
  • Loading branch information
bdlukaa committed Mar 20, 2022
1 parent a776fdb commit daa5a3e
Show file tree
Hide file tree
Showing 6 changed files with 106 additions and 144 deletions.
63 changes: 49 additions & 14 deletions lib/main.dart
Expand Up @@ -4,7 +4,7 @@ import 'package:flutter_localizations/flutter_localizations.dart';
import 'package:shared_preferences/shared_preferences.dart';
import 'package:provider/provider.dart';
import 'package:url_strategy/url_strategy.dart';
import 'package:bitsdojo_window/bitsdojo_window.dart';
import 'package:window_manager/window_manager.dart';

import './screens/root.dart';
import 'lang/lang.dart';
Expand All @@ -17,6 +17,16 @@ part 'app_builder.dart';

var _appBuilderKey = GlobalKey<AppBuilderState>();

/// Checks if the current environment is a desktop environment.
bool get isDesktop {
if (kIsWeb) return false;
return [
TargetPlatform.windows,
TargetPlatform.linux,
TargetPlatform.macOS,
].contains(defaultTargetPlatform);
}

void main() async {
WidgetsFlutterBinding.ensureInitialized();

Expand All @@ -26,15 +36,22 @@ void main() async {
await db.favorites();

if (kIsWeb) setPathUrlStrategy();
runApp(const MyApp());

doWhenWindowReady(() {
const initialSize = Size(600, 450);
appWindow.minSize = initialSize;
appWindow.size = initialSize;
appWindow.alignment = Alignment.center;
appWindow.show();
});
if (isDesktop) {
await WindowManager.instance.ensureInitialized();
windowManager.waitUntilReadyToShow().then((_) async {
await windowManager.setTitleBarStyle('hidden',
windowButtonVisibility: false);
await windowManager.setSize(const Size(755, 545));
await windowManager.setMinimumSize(const Size(755, 545));
await windowManager.center();
await windowManager.show();
await windowManager.setPreventClose(true);
await windowManager.setSkipTaskbar(false);
});
}

runApp(const MyApp());
}

class MyApp extends StatelessWidget {
Expand Down Expand Up @@ -64,11 +81,11 @@ class MyApp extends StatelessWidget {
if (isDesktop) {
return Scaffold(
body: Column(children: [
WindowTitleBarBox(
child: Row(children: [
Expanded(child: MoveWindow()),
const WindowButtons(),
]),
DragToMoveArea(
child: Row(
crossAxisAlignment: CrossAxisAlignment.start,
children: const [Spacer(), WindowButtons()],
),
),
Expanded(
child: child,
Expand Down Expand Up @@ -104,3 +121,21 @@ class NoGlowBehavior extends ScrollBehavior {
) =>
child;
}

class WindowButtons extends StatelessWidget {
const WindowButtons({Key? key}) : super(key: key);

@override
Widget build(BuildContext context) {
final ThemeData theme = Theme.of(context);

return SizedBox(
width: 138,
height: 50,
child: WindowCaption(
brightness: theme.brightness,
backgroundColor: Colors.transparent,
),
);
}
}
73 changes: 0 additions & 73 deletions lib/screens/root.dart
@@ -1,7 +1,3 @@
import 'dart:io';

import 'package:bitsdojo_window/bitsdojo_window.dart';
import 'package:flutter/foundation.dart';
import 'package:flutter/material.dart';
import 'package:flutter/services.dart';

Expand Down Expand Up @@ -127,72 +123,3 @@ class _RootState extends State<Root> with TickerProviderStateMixin {
);
}
}

bool get isDesktop {
if (kIsWeb) return false;
return Platform.isWindows || Platform.isLinux || Platform.isMacOS;
}

class WindowButtons extends StatefulWidget {
const WindowButtons({Key? key}) : super(key: key);

@override
_WindowButtonsState createState() => _WindowButtonsState();
}

class _WindowButtonsState extends State<WindowButtons> {
void maximizeOrRestore() {
setState(() {
appWindow.maximizeOrRestore();
});
}

@override
Widget build(BuildContext context) {
final bool isLight = Theme.of(context).brightness == Brightness.light;
final buttonColors = WindowButtonColors(
mouseOver: isLight ? Colors.orangeAccent : Colors.grey.shade800,
mouseDown: isLight ? Colors.orangeAccent.shade400 : Colors.grey.shade800,
iconNormal: Colors.white,
);

final closeButtonColors = WindowButtonColors(
mouseOver: const Color(0xFFD32F2F),
mouseDown: const Color(0xFFB71C1C),
iconNormal: isLight ? Colors.white : Colors.grey,
iconMouseOver: Colors.white,
);

return Row(
children: [
MinimizeWindowButton(colors: buttonColors),
appWindow.isMaximized
? RestoreWindowButton(
colors: buttonColors,
onPressed: maximizeOrRestore,
)
: MaximizeWindowButton(
colors: buttonColors,
onPressed: maximizeOrRestore,
),
CloseWindowButton(colors: closeButtonColors),
],
);
}
}

class RestoreWindowButton extends WindowButton {
RestoreWindowButton({
Key? key,
WindowButtonColors? colors,
VoidCallback? onPressed,
bool? animate,
}) : super(
key: key,
colors: colors,
animate: animate ?? false,
iconBuilder: (buttonContext) =>
RestoreIcon(color: buttonContext.iconColor),
onPressed: onPressed ?? () => appWindow.maximizeOrRestore(),
);
}
88 changes: 44 additions & 44 deletions pubspec.lock
Expand Up @@ -22,41 +22,6 @@ packages:
url: "https://pub.dartlang.org"
source: hosted
version: "2.8.2"
bitsdojo_window:
dependency: "direct main"
description:
name: bitsdojo_window
url: "https://pub.dartlang.org"
source: hosted
version: "0.1.1+1"
bitsdojo_window_linux:
dependency: transitive
description:
name: bitsdojo_window_linux
url: "https://pub.dartlang.org"
source: hosted
version: "0.1.1"
bitsdojo_window_macos:
dependency: transitive
description:
name: bitsdojo_window_macos
url: "https://pub.dartlang.org"
source: hosted
version: "0.1.0"
bitsdojo_window_platform_interface:
dependency: transitive
description:
name: bitsdojo_window_platform_interface
url: "https://pub.dartlang.org"
source: hosted
version: "0.1.0"
bitsdojo_window_windows:
dependency: transitive
description:
name: bitsdojo_window_windows
url: "https://pub.dartlang.org"
source: hosted
version: "0.1.0"
boolean_selector:
dependency: transitive
description:
Expand Down Expand Up @@ -152,14 +117,14 @@ packages:
name: flutter_colorpicker
url: "https://pub.dartlang.org"
source: hosted
version: "0.6.0"
version: "1.0.3"
flutter_launcher_icons:
dependency: "direct dev"
description:
name: flutter_launcher_icons
url: "https://pub.dartlang.org"
source: hosted
version: "0.9.1"
version: "0.9.2"
flutter_lints:
dependency: "direct dev"
description:
Expand Down Expand Up @@ -195,14 +160,14 @@ packages:
name: font_awesome_flutter
url: "https://pub.dartlang.org"
source: hosted
version: "9.2.0"
version: "10.0.0"
hive:
dependency: "direct main"
description:
name: hive
url: "https://pub.dartlang.org"
source: hosted
version: "2.0.4"
version: "2.0.6"
hive_flutter:
dependency: "direct main"
description:
Expand Down Expand Up @@ -237,7 +202,7 @@ packages:
name: image_picker
url: "https://pub.dartlang.org"
source: hosted
version: "0.8.4+4"
version: "0.8.4+11"
image_picker_for_web:
dependency: transitive
description:
Expand Down Expand Up @@ -384,14 +349,28 @@ packages:
name: provider
url: "https://pub.dartlang.org"
source: hosted
version: "6.0.1"
version: "6.0.2"
shared_preferences:
dependency: "direct main"
description:
name: shared_preferences
url: "https://pub.dartlang.org"
source: hosted
version: "2.0.8"
version: "2.0.13"
shared_preferences_android:
dependency: transitive
description:
name: shared_preferences_android
url: "https://pub.dartlang.org"
source: hosted
version: "2.0.11"
shared_preferences_ios:
dependency: transitive
description:
name: shared_preferences_ios
url: "https://pub.dartlang.org"
source: hosted
version: "2.1.0"
shared_preferences_linux:
dependency: transitive
description:
Expand Down Expand Up @@ -487,7 +466,21 @@ packages:
name: url_launcher
url: "https://pub.dartlang.org"
source: hosted
version: "6.0.12"
version: "6.0.20"
url_launcher_android:
dependency: transitive
description:
name: url_launcher_android
url: "https://pub.dartlang.org"
source: hosted
version: "6.0.15"
url_launcher_ios:
dependency: transitive
description:
name: url_launcher_ios
url: "https://pub.dartlang.org"
source: hosted
version: "6.0.15"
url_launcher_linux:
dependency: transitive
description:
Expand Down Expand Up @@ -544,6 +537,13 @@ packages:
url: "https://pub.dartlang.org"
source: hosted
version: "2.2.5"
window_manager:
dependency: "direct main"
description:
name: window_manager
url: "https://pub.dartlang.org"
source: hosted
version: "0.2.0"
xdg_directories:
dependency: transitive
description:
Expand All @@ -567,4 +567,4 @@ packages:
version: "3.1.0"
sdks:
dart: ">=2.14.0 <3.0.0"
flutter: ">=2.5.0"
flutter: ">=2.8.0"
18 changes: 9 additions & 9 deletions pubspec.yaml
Expand Up @@ -15,23 +15,23 @@ dependencies:
flutter_localizations:
sdk: flutter
color: ^3.0.0
flutter_colorpicker: ^0.6.0
flutter_colorpicker: ^1.0.3
fl_toast: ^3.1.0
font_awesome_flutter: ^9.2.0
image_picker: 0.8.4+4
font_awesome_flutter: ^10.0.0
image_picker: 0.8.4+11
path: ^1.8.0
provider: ^6.0.1
shared_preferences: ^2.0.8
hive: ^2.0.4
provider: ^6.0.2
shared_preferences: ^2.0.13
hive: ^2.0.6
hive_flutter: ^1.1.0
url_launcher: ^6.0.12
url_launcher: ^6.0.20
url_strategy: ^0.2.0
bitsdojo_window: ^0.1.1+1
window_manager: ^0.2.0

dev_dependencies:
flutter_test:
sdk: flutter
flutter_launcher_icons: ^0.9.1
flutter_launcher_icons: ^0.9.2
flutter_lints: ^1.0.4

flutter:
Expand Down
6 changes: 3 additions & 3 deletions windows/flutter/generated_plugin_registrant.cc
Expand Up @@ -6,12 +6,12 @@

#include "generated_plugin_registrant.h"

#include <bitsdojo_window_windows/bitsdojo_window_plugin.h>
#include <url_launcher_windows/url_launcher_plugin.h>
#include <window_manager/window_manager_plugin.h>

void RegisterPlugins(flutter::PluginRegistry* registry) {
BitsdojoWindowPluginRegisterWithRegistrar(
registry->GetRegistrarForPlugin("BitsdojoWindowPlugin"));
UrlLauncherPluginRegisterWithRegistrar(
registry->GetRegistrarForPlugin("UrlLauncherPlugin"));
WindowManagerPluginRegisterWithRegistrar(
registry->GetRegistrarForPlugin("WindowManagerPlugin"));
}
2 changes: 1 addition & 1 deletion windows/flutter/generated_plugins.cmake
Expand Up @@ -3,8 +3,8 @@
#

list(APPEND FLUTTER_PLUGIN_LIST
bitsdojo_window_windows
url_launcher_windows
window_manager
)

set(PLUGIN_BUNDLED_LIBRARIES)
Expand Down

0 comments on commit daa5a3e

Please sign in to comment.