diff --git a/lib/always-native/data/NativeData.dart b/lib/always-native/data/NativeData.dart index 4f6aa22..917da57 100644 --- a/lib/always-native/data/NativeData.dart +++ b/lib/always-native/data/NativeData.dart @@ -8,7 +8,6 @@ class NativeData { static NativePlatform getPlatform() { - // return NativePlatform.Linux; if(Platform.isMacOS) { return NativePlatform.macOS; @@ -17,6 +16,7 @@ class NativeData { return NativePlatform.Linux; } if(Platform.isWindows) { + return NativePlatform.macOS; // TODO fix after implementing fluentui return NativePlatform.Windows; } if(Platform.isAndroid) { diff --git a/lib/always-native/widgets/NativeApp.dart b/lib/always-native/widgets/NativeApp.dart index aef2eb8..6edabef 100644 --- a/lib/always-native/widgets/NativeApp.dart +++ b/lib/always-native/widgets/NativeApp.dart @@ -1,4 +1,5 @@ import 'package:app/always-native/data/NativeData.dart'; +import 'package:fluent_ui/fluent_ui.dart' as fluent_ui; import 'package:flutter/material.dart'; import 'package:flutter/widgets.dart'; import 'package:macos_ui/macos_ui.dart'; @@ -52,6 +53,16 @@ class _NativeAppState extends State<NativeApp> { debugShowCheckedModeBanner: widget.debugShowCheckedModeBanner, ); }); + } else if (platform == NativePlatform.Windows) { + return fluent_ui.FluentApp( + title: 'MyApp', + darkTheme: fluent_ui.ThemeData( + brightness: Brightness.dark, + ), + theme: fluent_ui.ThemeData( + ), + routes: widget.routes!, + ); } return MaterialApp( diff --git a/lib/always-native/widgets/NativeAppBar.dart b/lib/always-native/widgets/NativeAppBar.dart index 6e4b3cb..12e12c3 100644 --- a/lib/always-native/widgets/NativeAppBar.dart +++ b/lib/always-native/widgets/NativeAppBar.dart @@ -4,6 +4,7 @@ import 'package:flutter/material.dart'; import 'package:get/get.dart'; import 'package:macos_ui/macos_ui.dart'; import 'dart:io' show Platform; +import 'package:fluent_ui/fluent_ui.dart' as fluent_ui; import '../data/NativeData.dart'; @@ -47,6 +48,35 @@ class NativeAppBar extends StatelessWidget { actions: macosuiActions, ), ); + } else if(platform == NativePlatform.Windows) { + + List<Widget> fluentActions = []; + if (actions != null) { + fluentActions.add(fluent_ui.Spacer()); + int index = -1; + for (NativeAppBarAction action in actions!) { + index++; + fluentActions.add(NativeTextButton( + icon: action.icon, + onPressed: action.onTap, + child: Text(action.label), + )); + } + } + + + return SizedBox( + height: kToolbarHeight, + child: fluent_ui.NavigationView( + appBar: fluent_ui.NavigationAppBar( + title: title == null ? null : Text(title!), + actions: Row(children: fluentActions), + /// If automaticallyImplyLeading is true, a 'back button' will be added to + /// app bar. This property can be overritten by [leading] + automaticallyImplyLeading: true, + ), + ), + ); } else { List<Widget> materialActions = []; if (actions != null) { diff --git a/lib/always-native/widgets/NativeMaterial.dart b/lib/always-native/widgets/NativeMaterial.dart index d2b7b91..c518c80 100644 --- a/lib/always-native/widgets/NativeMaterial.dart +++ b/lib/always-native/widgets/NativeMaterial.dart @@ -2,6 +2,7 @@ import 'package:flutter/material.dart'; import 'package:yaru/yaru.dart'; import '../data/NativeData.dart'; +import 'package:fluent_ui/fluent_ui.dart' as fluent_ui; class NativeMaterial extends StatelessWidget { final Widget child; @@ -13,24 +14,36 @@ class NativeMaterial extends StatelessWidget { Widget build(BuildContext context) { NativePlatform platform = NativeData.getPlatform(); - if (platform == NativePlatform.macOS) { + if (platform == NativePlatform.macOS) { return Material( color: Colors.transparent, child: Theme( - data: ThemeData(brightness: ( MediaQuery.platformBrightnessOf(context) == Brightness.dark) ? Brightness.dark : Brightness.light), + data: ThemeData( + brightness: + (MediaQuery.platformBrightnessOf(context) == Brightness.dark) + ? Brightness.dark + : Brightness.light), child: child, ), ); - + } else if (platform == NativePlatform.Linux) { + return Material( + color: Colors.transparent, + child: YaruTheme( + // data: YaruThemeData(brightness: ( MediaQuery.platformBrightnessOf(context) == Brightness.dark) ? Brightness.dark : Brightness.light), + child: child, + ), + ); + } else if (platform == NativePlatform.Windows) { + return fluent_ui.NavigationView( + content: Material(child: child), + ); } return Material( color: Colors.transparent, - child: YaruTheme( - // data: YaruThemeData(brightness: ( MediaQuery.platformBrightnessOf(context) == Brightness.dark) ? Brightness.dark : Brightness.light), - child: child, - ), + child: child, ); } } diff --git a/lib/always-native/widgets/NativeWindow.dart b/lib/always-native/widgets/NativeWindow.dart index bec5298..18311d4 100644 --- a/lib/always-native/widgets/NativeWindow.dart +++ b/lib/always-native/widgets/NativeWindow.dart @@ -1,7 +1,9 @@ +import 'package:app/always-native/widgets/NativeMaterial.dart'; import 'package:flutter/material.dart'; import 'package:flutter/widgets.dart'; import 'package:macos_ui/macos_ui.dart'; import 'dart:io' show Platform; +import 'package:fluent_ui/fluent_ui.dart' as fluent_ui; import '../data/NativeData.dart'; @@ -31,6 +33,10 @@ class _NativeWindowState extends State<NativeWindow> { ), child: widget.child, ); + } else if(platform == NativePlatform.Windows) { + return fluent_ui.NavigationView( + content: NativeMaterial(child: widget.child), + ); } else { return Scaffold( body: widget.child, diff --git a/lib/screens/MainScreen.dart b/lib/screens/MainScreen.dart index d8ce96e..430a0cd 100644 --- a/lib/screens/MainScreen.dart +++ b/lib/screens/MainScreen.dart @@ -1,6 +1,7 @@ import 'dart:convert'; import 'dart:io'; +import 'package:app/always-native/data/NativeData.dart'; import 'package:app/always-native/widgets/NativeWindow.dart'; import 'package:app/data/MultipassInstanceObject.dart'; import 'package:app/screens/CreateInstance.dart'; @@ -32,36 +33,35 @@ class _MainScreenState extends State<MainScreen> { bool isInstalled = true; loadList() async { - try { // var result = await Process.run('which', [GlobalUtils.multipassPath]); // debugPrint('which output: '); // debugPrint(result.stdout.toString()); - if (GlobalUtils.multipassPath == '') { - var whichResult = await Process.run('which', ['multipass']); + if (NativeData.getPlatform() == NativePlatform.macOS) { + GlobalUtils.multipassPath = '/usr/local/bin/multipass'; + } else { + var whichResult = await Process.run('which', ['multipass']); - // debugPrint('whichResult.stdout: ' + whichResult.stdout); + // debugPrint('whichResult.stdout: ' + whichResult.stdout); - if (whichResult.stdout.contains('multipass')) { - isInstalled = true; - GlobalUtils.multipassPath = whichResult.stdout.replaceAll("\n", ''); - - } else { - isInstalled = false; - setState(() {}); + if (whichResult.stdout.contains('multipass')) { + isInstalled = true; + GlobalUtils.multipassPath = whichResult.stdout.replaceAll("\n", ''); + } else { + isInstalled = false; + setState(() {}); + } } } else { isInstalled = true; } - if(isInstalled) { + if (isInstalled) { try { - list = []; - var result = await Process.run( GlobalUtils.multipassPath, ['list', '--format=json']); @@ -70,16 +70,14 @@ class _MainScreenState extends State<MainScreen> { var rawList = json.decode(result.stdout)['list']; // replace with list for (var rawInstance in rawList) { MultipassInstanceObject multipassInstanceObject = - MultipassInstanceObject( - name: rawInstance['name'], - release: rawInstance['release'], - state: rawInstance['state']); + MultipassInstanceObject( + name: rawInstance['name'], + release: rawInstance['release'], + state: rawInstance['state']); list?.add(multipassInstanceObject); } - setState(() { - - }); - } catch(ex) { + setState(() {}); + } catch (ex) { debugPrint(ex.toString()); } } diff --git a/pubspec.lock b/pubspec.lock index 561629f..fdfd3a1 100644 --- a/pubspec.lock +++ b/pubspec.lock @@ -127,6 +127,13 @@ packages: url: "https://pub.dartlang.org" source: hosted version: "5.0.1" + fluent_ui: + dependency: "direct main" + description: + name: fluent_ui + url: "https://pub.dartlang.org" + source: hosted + version: "3.12.0" flutter: dependency: "direct main" description: flutter @@ -146,6 +153,11 @@ packages: url: "https://pub.dartlang.org" source: hosted version: "2.0.1" + flutter_localizations: + dependency: transitive + description: flutter + source: sdk + version: "0.0.0" flutter_platform_alert: dependency: "direct main" description: @@ -219,6 +231,13 @@ packages: url: "https://pub.dartlang.org" source: hosted version: "3.2.0" + intl: + dependency: transitive + description: + name: intl + url: "https://pub.dartlang.org" + source: hosted + version: "0.17.0" js: dependency: transitive description: @@ -366,6 +385,13 @@ packages: url: "https://pub.dartlang.org" source: hosted version: "2.1.1" + recase: + dependency: transitive + description: + name: recase + url: "https://pub.dartlang.org" + source: hosted + version: "4.0.0" screen_retriever: dependency: transitive description: @@ -373,6 +399,13 @@ packages: url: "https://pub.dartlang.org" source: hosted version: "0.1.3" + scroll_pos: + dependency: transitive + description: + name: scroll_pos + url: "https://pub.dartlang.org" + source: hosted + version: "0.3.0" sky_engine: dependency: transitive description: flutter diff --git a/pubspec.yaml b/pubspec.yaml index 3ec3cab..dcfaa88 100644 --- a/pubspec.yaml +++ b/pubspec.yaml @@ -15,7 +15,7 @@ publish_to: 'none' # Remove this line if you wish to publish to pub.dev # In iOS, build-name is used as CFBundleShortVersionString while build-number used as CFBundleVersion. # Read more about iOS versioning at # https://developer.apple.com/library/archive/documentation/General/Reference/InfoPlistKeyReference/Articles/CoreFoundationKeys.html -version: 1.0.0+1 +version: 1.0.1+2 environment: sdk: ">=2.17.6 <3.0.0" @@ -47,6 +47,7 @@ dependencies: flutter_platform_widgets: ^2.0.0 macos_ui: ^1.7.5 yaru: ^0.4.1 + fluent_ui: ^3.12.0 flutter_icons: android: "launcher_icon"