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.
///
/// In en, this message translates to:
/// **'Setting'**
/// **'Settings'**
String get setting;
/// No description provided for @sftpDlPrepare.

View File

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

View File

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

View File

@@ -3,4 +3,4 @@ distributionBase=GRADLE_USER_HOME
distributionPath=wrapper/dists
zipStoreBase=GRADLE_USER_HOME
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);
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;
return ValueListenableBuilder<int>(
@@ -47,44 +27,26 @@ class MyApp extends StatelessWidget {
final ok = tMode >= 0 && tMode <= ThemeMode.values.length - 1;
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(
debugShowCheckedModeBanner: false,
localizationsDelegates: S.localizationsDelegates,
supportedLocales: S.supportedLocales,
title: BuildData.name,
themeMode: themeMode,
theme: theme,
darkTheme: darkTheme,
theme: ThemeData.light(useMaterial3: true).copyWith(
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(),
);
},

View File

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

View File

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

View File

@@ -110,7 +110,7 @@ class _MyHomePageState extends State<MyHomePage>
return Scaffold(
drawer: _buildDrawer(),
appBar: AppBar(
title: Text(tabTitleName(context, _selectIndex), style: textSize18),
title: Text(tabTitleName(context, _selectIndex)),
actions: [
IconButton(
icon: const Icon(Icons.developer_mode, size: 23),
@@ -123,68 +123,47 @@ class _MyHomePageState extends State<MyHomePage>
body: PageView(
physics: const ClampingScrollPhysics(),
controller: _pageController,
onPageChanged: (i) {
onPageChanged: (index) {
setState(() {
_selectIndex = index;
FocusScope.of(context).requestFocus(FocusNode());
_selectIndex = i;
setState(() {});
});
},
children: const [ServerPage(), ConvertPage(), PingPage()],
),
bottomNavigationBar: _buildBottom(context),
bottomNavigationBar: _buildBottomBar(context),
);
}
Widget _buildBottomItem(int idx, NavigationItem item, bool isSelected) {
final width = _width / tabItems.length;
return AnimatedContainer(
duration: const Duration(milliseconds: 377),
curve: Curves.fastOutSlowIn,
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: () {
Widget _buildBottomBar(BuildContext context){
return NavigationBar(
selectedIndex: _selectIndex,
animationDuration: const Duration(milliseconds: 250),
onDestinationSelected: (int index) {
setState(() {
_pageController.animateToPage(idx,
_selectIndex = index;
_pageController.animateToPage(index,
duration: const Duration(milliseconds: 677),
curve: Curves.fastLinearToSlowEaseIn);
});
},
labelBehavior: NavigationDestinationLabelBehavior.onlyShowSelected,
destinations: const [
NavigationDestination(
icon: Icon(Icons.cloud_outlined),
label: 'Server',
selectedIcon: Icon(Icons.cloud),
),
);
}
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.code),
label: 'Convert',
),
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();
return ListView.separated(
padding: const EdgeInsets.all(7),
padding: const EdgeInsets.fromLTRB(7, 10, 7, 7),
controller: ScrollController(),
physics: const AlwaysScrollableScrollPhysics(),
itemBuilder: (ctx, idx) {

View File

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

View File

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

View File

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