Merge pull request #9 from wyq0918dev/md3

Modify user interface to material3
This commit is contained in:
Caten
2024-01-12 18:57:06 +08:00
committed by GitHub
3 changed files with 44 additions and 17 deletions

View File

@@ -25,6 +25,7 @@ import 'dart:math';
//import 'package:flutter/services.dart'; //import 'package:flutter/services.dart';
import 'package:clipboard/clipboard.dart'; import 'package:clipboard/clipboard.dart';
import 'package:dynamic_color/dynamic_color.dart';
import 'package:flutter/gestures.dart'; import 'package:flutter/gestures.dart';
import 'package:flutter_pty/flutter_pty.dart'; import 'package:flutter_pty/flutter_pty.dart';
import 'package:permission_handler/permission_handler.dart'; import 'package:permission_handler/permission_handler.dart';
@@ -49,16 +50,25 @@ class MyApp extends StatelessWidget {
@override @override
Widget build(BuildContext context) { Widget build(BuildContext context) {
return DynamicColorBuilder(
builder: (ColorScheme? lightDynamic, ColorScheme? darkDynamic) {
return MaterialApp( return MaterialApp(
title: 'Tiny Computer', title: 'Tiny Computer',
theme: ThemeData( theme: ThemeData(
colorScheme: ColorScheme.fromSeed(seedColor: Colors.deepPurple), colorScheme: lightDynamic,
useMaterial3: true,
//fontFamily: "FiraCode",
),
darkTheme: ThemeData(
colorScheme: darkDynamic,
useMaterial3: true, useMaterial3: true,
//fontFamily: "FiraCode", //fontFamily: "FiraCode",
), ),
home: const MyHomePage(title: 'Tiny Computer'), home: const MyHomePage(title: 'Tiny Computer'),
); );
} }
);
}
} }
@@ -1516,7 +1526,6 @@ class _MyHomePageState extends State<MyHomePage> {
return Scaffold( return Scaffold(
appBar: AppBar( appBar: AppBar(
backgroundColor: Theme.of(context).colorScheme.inversePrimary,
title: Text(isLoadingComplete?Util.getCurrentProp("name"):widget.title), title: Text(isLoadingComplete?Util.getCurrentProp("name"):widget.title),
), ),
body: isLoadingComplete?Column(mainAxisSize: MainAxisSize.min, children: [ body: isLoadingComplete?Column(mainAxisSize: MainAxisSize.min, children: [
@@ -1564,15 +1573,25 @@ class _MyHomePageState extends State<MyHomePage> {
}))]):const LoadingPage(), }))]):const LoadingPage(),
bottomNavigationBar: ValueListenableBuilder(valueListenable: G.pageIndex, builder:(context, value, child) { bottomNavigationBar: ValueListenableBuilder(valueListenable: G.pageIndex, builder:(context, value, child) {
return Visibility(visible: isLoadingComplete, return Visibility(visible: isLoadingComplete,
child: BottomNavigationBar(currentIndex: G.pageIndex.value, // child: BottomNavigationBar(currentIndex: G.pageIndex.value,
onTap: (index) { // onTap: (index) {
// G.pageIndex.value = index;
// },
// items: const [
// BottomNavigationBarItem(icon: Icon(Icons.monitor), label: "终端"),
// BottomNavigationBarItem(icon: Icon(Icons.video_settings), label: "控制"),
// ],
// )
child: NavigationBar(
selectedIndex: G.pageIndex.value,
destinations: const [
NavigationDestination(icon: Icon(Icons.monitor), label: "终端"),
NavigationDestination(icon: Icon(Icons.video_settings), label: "控制")
],
onDestinationSelected: (index) {
G.pageIndex.value = index; G.pageIndex.value = index;
}, },
items: const [ ),
BottomNavigationBarItem(icon: Icon(Icons.monitor), label: "终端"),
BottomNavigationBarItem(icon: Icon(Icons.video_settings), label: "控制"),
],
)
);}), );}),
floatingActionButton: ValueListenableBuilder(valueListenable: G.pageIndex, builder:(context, value, child) { floatingActionButton: ValueListenableBuilder(valueListenable: G.pageIndex, builder:(context, value, child) {
return Visibility(visible: isLoadingComplete && (value == 0), return Visibility(visible: isLoadingComplete && (value == 0),

View File

@@ -73,6 +73,14 @@ packages:
url: "https://pub.dev" url: "https://pub.dev"
source: hosted source: hosted
version: "0.7.10" version: "0.7.10"
dynamic_color:
dependency: "direct main"
description:
name: dynamic_color
sha256: a866f1f8947bfdaf674d7928e769eac7230388a2e7a2542824fad4bb5b87be3b
url: "https://pub.dev"
source: hosted
version: "1.6.9"
equatable: equatable:
dependency: transitive dependency: transitive
description: description:

View File

@@ -44,7 +44,7 @@ dependencies:
clipboard: ^0.1.3 clipboard: ^0.1.3
ffmpeg_kit_flutter_full_gpl: ^6.0.3 ffmpeg_kit_flutter_full_gpl: ^6.0.3
wakelock_plus: ^1.1.4 wakelock_plus: ^1.1.4
dynamic_color: ^1.6.9
# The following adds the Cupertino Icons font to your application. # The following adds the Cupertino Icons font to your application.
# Use with the CupertinoIcons class for iOS style icons. # Use with the CupertinoIcons class for iOS style icons.