Skip to content

Commit

Permalink
Added fluent ui, yet to be fully implemented
Browse files Browse the repository at this point in the history
  • Loading branch information
alinoaimi committed Sep 21, 2022
1 parent 4dd6460 commit a40c6cb
Show file tree
Hide file tree
Showing 8 changed files with 123 additions and 31 deletions.
2 changes: 1 addition & 1 deletion lib/always-native/data/NativeData.dart
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,6 @@ class NativeData {

static NativePlatform getPlatform() {

// return NativePlatform.Linux;

if(Platform.isMacOS) {
return NativePlatform.macOS;
Expand All @@ -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) {
Expand Down
11 changes: 11 additions & 0 deletions lib/always-native/widgets/NativeApp.dart
Original file line number Diff line number Diff line change
@@ -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';
Expand Down Expand Up @@ -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(
Expand Down
30 changes: 30 additions & 0 deletions lib/always-native/widgets/NativeAppBar.dart
Original file line number Diff line number Diff line change
Expand Up @@ -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';

Expand Down Expand Up @@ -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) {
Expand Down
27 changes: 20 additions & 7 deletions lib/always-native/widgets/NativeMaterial.dart
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand All @@ -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,
);
}
}
6 changes: 6 additions & 0 deletions lib/always-native/widgets/NativeWindow.dart
Original file line number Diff line number Diff line change
@@ -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';

Expand Down Expand Up @@ -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,
Expand Down
42 changes: 20 additions & 22 deletions lib/screens/MainScreen.dart
Original file line number Diff line number Diff line change
@@ -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';
Expand Down Expand Up @@ -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']);

Expand All @@ -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());
}
}
Expand Down
33 changes: 33 additions & 0 deletions pubspec.lock
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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:
Expand Down Expand Up @@ -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:
Expand Down Expand Up @@ -366,13 +385,27 @@ 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:
name: screen_retriever
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
Expand Down
3 changes: 2 additions & 1 deletion pubspec.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand Down Expand Up @@ -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"
Expand Down

0 comments on commit a40c6cb

Please sign in to comment.