use Material3, changed color selection

This commit is contained in:
Thomas
2023-05-06 12:53:32 +02:00
parent 90e25856cf
commit e61597b3ce
12 changed files with 67 additions and 121 deletions

View File

@@ -942,7 +942,7 @@ abstract class S {
/// No description provided for @setting. /// No description provided for @setting.
/// ///
/// In en, this message translates to: /// In en, this message translates to:
/// **'Setting'** /// **'Settings'**
String get setting; String get setting;
/// No description provided for @sftpDlPrepare. /// No description provided for @sftpDlPrepare.

View File

@@ -454,7 +454,7 @@ class SEn extends S {
String get serverTabUnkown => 'Unknown state'; String get serverTabUnkown => 'Unknown state';
@override @override
String get setting => 'Setting'; String get setting => 'Settings';
@override @override
String get sftpDlPrepare => 'Preparing to connect...'; String get sftpDlPrepare => 'Preparing to connect...';

View File

@@ -1,5 +1,5 @@
buildscript { buildscript {
ext.kotlin_version = '1.6.10' ext.kotlin_version = '1.8.0'
repositories { repositories {
google() google()
mavenCentral() mavenCentral()

View File

@@ -3,4 +3,4 @@ distributionBase=GRADLE_USER_HOME
distributionPath=wrapper/dists distributionPath=wrapper/dists
zipStoreBase=GRADLE_USER_HOME zipStoreBase=GRADLE_USER_HOME
zipStorePath=wrapper/dists zipStorePath=wrapper/dists
distributionUrl=https\://services.gradle.org/distributions/gradle-7.0.2-all.zip distributionUrl=https\://services.gradle.org/distributions/gradle-7.6-all.zip

View File

@@ -19,26 +19,6 @@ class MyApp extends StatelessWidget {
setTransparentNavigationBar(context); setTransparentNavigationBar(context);
primaryColor = Color(_setting.primaryColor.fetch()!); primaryColor = Color(_setting.primaryColor.fetch()!);
final textStyle = TextStyle(color: primaryColor);
final materialColor = primaryColor.materialStateColor;
final materialColorAlpha = primaryColor.withOpacity(0.7).materialStateColor;
final fabTheme =
FloatingActionButtonThemeData(backgroundColor: primaryColor);
final switchTheme = SwitchThemeData(
thumbColor: materialColor,
trackColor: materialColorAlpha,
);
final appBarTheme = AppBarTheme(backgroundColor: primaryColor);
final iconTheme = IconThemeData(color: primaryColor);
final inputDecorationTheme = InputDecorationTheme(
labelStyle: textStyle,
focusedBorder: UnderlineInputBorder(
borderSide: BorderSide(color: primaryColor),
),
);
final radioTheme = RadioThemeData(
fillColor: materialColor,
);
final primarySwatch = primaryColor.materialColor; final primarySwatch = primaryColor.materialColor;
return ValueListenableBuilder<int>( return ValueListenableBuilder<int>(
@@ -47,44 +27,26 @@ class MyApp extends StatelessWidget {
final ok = tMode >= 0 && tMode <= ThemeMode.values.length - 1; final ok = tMode >= 0 && tMode <= ThemeMode.values.length - 1;
final themeMode = ok ? ThemeMode.values[tMode] : ThemeMode.system; final themeMode = ok ? ThemeMode.values[tMode] : ThemeMode.system;
final theme = ThemeData(
useMaterial3: false,
primaryColor: primaryColor,
primarySwatch: primarySwatch,
appBarTheme: appBarTheme,
floatingActionButtonTheme: fabTheme,
iconTheme: iconTheme,
primaryIconTheme: iconTheme,
switchTheme: switchTheme,
inputDecorationTheme: inputDecorationTheme,
radioTheme: radioTheme,
);
final darkTheme = ThemeData(
useMaterial3: false,
primaryColor: primaryColor,
primarySwatch: primarySwatch,
floatingActionButtonTheme: fabTheme,
iconTheme: iconTheme,
primaryIconTheme: iconTheme,
switchTheme: switchTheme,
inputDecorationTheme: inputDecorationTheme,
radioTheme: radioTheme,
brightness: Brightness.dark,
colorScheme: ColorScheme.fromSwatch(
primarySwatch: primaryColor.materialColor,
brightness: Brightness.dark,
accentColor: primaryColor,
),
);
return MaterialApp( return MaterialApp(
debugShowCheckedModeBanner: false, debugShowCheckedModeBanner: false,
localizationsDelegates: S.localizationsDelegates, localizationsDelegates: S.localizationsDelegates,
supportedLocales: S.supportedLocales, supportedLocales: S.supportedLocales,
title: BuildData.name, title: BuildData.name,
themeMode: themeMode, themeMode: themeMode,
theme: theme, theme: ThemeData.light(useMaterial3: true).copyWith(
darkTheme: darkTheme, colorScheme: ColorScheme.fromSwatch(
primarySwatch: primarySwatch,
accentColor: primaryColor,
),
switchTheme: ThemeData.light(useMaterial3: true).switchTheme,
),
darkTheme: ThemeData.dark(useMaterial3: true).copyWith(
colorScheme: ColorScheme.fromSwatch(
brightness: Brightness.dark,
primarySwatch: primarySwatch,
accentColor: primaryColor,
),
),
home: const MyHomePage(), home: const MyHomePage(),
); );
}, },

View File

@@ -29,6 +29,7 @@ void showSnackBarWithAction(BuildContext context, String content, String action,
GestureTapCallback onTap) { GestureTapCallback onTap) {
ScaffoldMessenger.of(context).showSnackBar(SnackBar( ScaffoldMessenger.of(context).showSnackBar(SnackBar(
content: Text(content), content: Text(content),
behavior: SnackBarBehavior.floating,
action: SnackBarAction( action: SnackBarAction(
label: action, label: action,
onPressed: onTap, onPressed: onTap,

View File

@@ -140,7 +140,7 @@
"serverTabLoading": "Loading...", "serverTabLoading": "Loading...",
"serverTabPlzSave": "Please 'save' this private key again.", "serverTabPlzSave": "Please 'save' this private key again.",
"serverTabUnkown": "Unknown state", "serverTabUnkown": "Unknown state",
"setting": "Setting", "setting": "Settings",
"sftpDlPrepare": "Preparing to connect...", "sftpDlPrepare": "Preparing to connect...",
"sftpNoDownloadTask": "No download task.", "sftpNoDownloadTask": "No download task.",
"sftpSSHConnected": "SFTP Connected", "sftpSSHConnected": "SFTP Connected",

View File

@@ -110,7 +110,7 @@ class _MyHomePageState extends State<MyHomePage>
return Scaffold( return Scaffold(
drawer: _buildDrawer(), drawer: _buildDrawer(),
appBar: AppBar( appBar: AppBar(
title: Text(tabTitleName(context, _selectIndex), style: textSize18), title: Text(tabTitleName(context, _selectIndex)),
actions: [ actions: [
IconButton( IconButton(
icon: const Icon(Icons.developer_mode, size: 23), icon: const Icon(Icons.developer_mode, size: 23),
@@ -123,68 +123,47 @@ class _MyHomePageState extends State<MyHomePage>
body: PageView( body: PageView(
physics: const ClampingScrollPhysics(), physics: const ClampingScrollPhysics(),
controller: _pageController, controller: _pageController,
onPageChanged: (i) { onPageChanged: (index) {
setState(() {
_selectIndex = index;
FocusScope.of(context).requestFocus(FocusNode()); FocusScope.of(context).requestFocus(FocusNode());
_selectIndex = i; });
setState(() {});
}, },
children: const [ServerPage(), ConvertPage(), PingPage()], children: const [ServerPage(), ConvertPage(), PingPage()],
), ),
bottomNavigationBar: _buildBottom(context), bottomNavigationBar: _buildBottomBar(context),
); );
} }
Widget _buildBottomItem(int idx, NavigationItem item, bool isSelected) { Widget _buildBottomBar(BuildContext context){
final width = _width / tabItems.length; return NavigationBar(
return AnimatedContainer( selectedIndex: _selectIndex,
duration: const Duration(milliseconds: 377), animationDuration: const Duration(milliseconds: 250),
curve: Curves.fastOutSlowIn, onDestinationSelected: (int index) {
height: 50,
width: isSelected ? width : width - 17,
decoration: BoxDecoration(
color: isSelected
? _bottomItemOverlayColor.resolve(context)
: Colors.transparent,
borderRadius: const BorderRadius.all(
Radius.circular(50),
),
),
child: IconButton(
icon: Icon(item.icon),
tooltip: tabTitleName(context, idx),
splashRadius: width / 3.3,
padding: const EdgeInsets.only(left: 17, right: 17),
onPressed: () {
setState(() { setState(() {
_pageController.animateToPage(idx, _selectIndex = index;
_pageController.animateToPage(index,
duration: const Duration(milliseconds: 677), duration: const Duration(milliseconds: 677),
curve: Curves.fastLinearToSlowEaseIn); curve: Curves.fastLinearToSlowEaseIn);
}); });
}, },
labelBehavior: NavigationDestinationLabelBehavior.onlyShowSelected,
destinations: const [
NavigationDestination(
icon: Icon(Icons.cloud_outlined),
label: 'Server',
selectedIcon: Icon(Icons.cloud),
), ),
); NavigationDestination(
} icon: Icon(Icons.code),
label: 'Convert',
Widget _buildBottom(BuildContext context) {
return SafeArea(
child: Container(
height: 56,
padding: const EdgeInsets.only(left: 8, top: 4, bottom: 4, right: 8),
width: _width,
child: Row(
mainAxisAlignment: MainAxisAlignment.spaceEvenly,
children: tabItems.map(
(item) {
int itemIndex = tabItems.indexOf(item);
return _buildBottomItem(
itemIndex,
item,
_selectIndex == itemIndex,
);
},
).toList(),
), ),
NavigationDestination(
icon: Icon(Icons.leak_add),
label: 'Ping',
selectedIcon: Icon(Icons.leak_add_outlined),
), ),
],
); );
} }

View File

@@ -77,7 +77,7 @@ class _ServerPageState extends State<ServerPage>
} }
final keys = pro.servers.keys.toList(); final keys = pro.servers.keys.toList();
return ListView.separated( return ListView.separated(
padding: const EdgeInsets.all(7), padding: const EdgeInsets.fromLTRB(7, 10, 7, 7),
controller: ScrollController(), controller: ScrollController(),
physics: const AlwaysScrollableScrollPhysics(), physics: const AlwaysScrollableScrollPhysics(),
itemBuilder: (ctx, idx) { itemBuilder: (ctx, idx) {

View File

@@ -243,7 +243,9 @@ class _SettingPageState extends State<SettingPage> {
Widget _buildAppColorPicker() { Widget _buildAppColorPicker() {
return MaterialColorPicker( return MaterialColorPicker(
shrinkWrap: true, shrinkWrap: true,
onColorChange: (Color color) { allowShades: false,
onMainColorChange: (ColorSwatch<dynamic>? color) {
if(color == null) return;
_selectedColorValue = color.value; _selectedColorValue = color.value;
}, },
selectedColor: primaryColor, selectedColor: primaryColor,

View File

@@ -1006,9 +1006,11 @@ packages:
xterm: xterm:
dependency: "direct main" dependency: "direct main"
description: description:
path: "../xterm.dart" path: "."
relative: true ref: master
source: path resolved-ref: "8039a582d855428cec49b23641bcfcafd6682574"
url: "https://github.com/lollipopkit/xterm.dart"
source: git
version: "3.4.1" version: "3.4.1"
yaml: yaml:
dependency: transitive dependency: transitive

View File

@@ -57,10 +57,10 @@ dependencies:
share_plus_web: ^3.1.0 share_plus_web: ^3.1.0
# xterm: ^3.4.1 # xterm: ^3.4.1
xterm: xterm:
path: ../xterm.dart #path: ../xterm.dart
# git: git:
# ref: master ref: master
# url: https://github.com/lollipopkit/xterm.dart url: https://github.com/lollipopkit/xterm.dart
file_picker: ^5.2.5 file_picker: ^5.2.5
plain_notification_token: ^0.0.4 plain_notification_token: ^0.0.4