#57 AMOLED theme

This commit is contained in:
lollipopkit
2023-06-01 15:18:54 +08:00
parent 6091cd0da8
commit 026e951604
9 changed files with 95 additions and 84 deletions

View File

@@ -23,9 +23,16 @@ class MyApp extends StatelessWidget {
valueListenable: _setting.themeMode.listenable(),
builder: (_, tMode, __) {
final ok = tMode >= 0 && tMode <= ThemeMode.values.length - 1;
final themeMode = ok ? ThemeMode.values[tMode] : ThemeMode.system;
// Issue #57
// if not [ok] -> [AMOLED] mode, use [ThemeMode.dark]
final themeMode = ok ? ThemeMode.values[tMode] : ThemeMode.dark;
final localeStr = _setting.locale.fetch();
final locale = localeStr?.toLocale;
final darkTheme = ThemeData(
useMaterial3: true,
brightness: Brightness.dark,
colorSchemeSeed: primaryColor,
);
return MaterialApp(
debugShowCheckedModeBanner: false,
@@ -38,11 +45,30 @@ class MyApp extends StatelessWidget {
useMaterial3: true,
colorSchemeSeed: primaryColor,
),
darkTheme: ThemeData(
useMaterial3: true,
brightness: Brightness.dark,
colorSchemeSeed: primaryColor,
),
darkTheme: ok
? darkTheme
: darkTheme.copyWith(
scaffoldBackgroundColor: Colors.black,
dialogBackgroundColor: Colors.black,
drawerTheme: const DrawerThemeData(
backgroundColor: Colors.black,
),
appBarTheme: const AppBarTheme(
backgroundColor: Colors.black,
),
bottomSheetTheme: const BottomSheetThemeData(
backgroundColor: Colors.black,
),
listTileTheme: const ListTileThemeData(
tileColor: Colors.black12,
),
cardTheme: const CardTheme(
color: Colors.black12,
),
navigationBarTheme: const NavigationBarThemeData(
backgroundColor: Colors.black,
),
),
home: const HomePage(),
);
},

View File

@@ -2,8 +2,8 @@
class BuildData {
static const String name = "ServerBox";
static const int build = 333;
static const int build = 341;
static const String engine = "3.10.2";
static const String buildAt = "2023-05-28 19:42:38.911830";
static const int modifications = 7;
static const String buildAt = "2023-05-31 19:23:57.263324";
static const int modifications = 6;
}

View File

@@ -142,7 +142,6 @@ class _HomePageState extends State<HomePage>
);
});
},
elevation: 0.47,
labelBehavior: NavigationDestinationLabelBehavior.onlyShowSelected,
destinations: [
NavigationDestination(

View File

@@ -149,22 +149,22 @@ class _ServerPageState extends State<ServerPage>
(pro.servers[e]?.spi.tags?.contains(_tag) ?? false))
.toList();
return AnimationLimiter(
key: ValueKey(_tag),
key: ValueKey(_tag),
child: ReorderableListView.builder(
header: _buildTagsSwitcher(pro),
padding: const EdgeInsets.fromLTRB(7, 10, 7, 7),
physics: const AlwaysScrollableScrollPhysics(),
onReorder: (oldIndex, newIndex) => setState(() {
pro.serverOrder.moveById(
filtered[oldIndex],
filtered[newIndex],
_settingStore.serverOrder,
);
}),
itemBuilder: (context, index) =>
_buildEachServerCard(pro.servers[filtered[index]], index),
itemCount: filtered.length,
));
header: _buildTagsSwitcher(pro),
padding: const EdgeInsets.fromLTRB(7, 10, 7, 7),
physics: const AlwaysScrollableScrollPhysics(),
onReorder: (oldIndex, newIndex) => setState(() {
pro.serverOrder.moveById(
filtered[oldIndex],
filtered[newIndex],
_settingStore.serverOrder,
);
}),
itemBuilder: (context, index) =>
_buildEachServerCard(pro.servers[filtered[index]], index),
itemCount: filtered.length,
));
},
),
);

View File

@@ -365,15 +365,17 @@ class _SettingPageState extends State<SettingPage> {
}
Widget _buildThemeMode() {
final items = ThemeMode.values.map(
(e) {
final str = _buildThemeModeStr(e.index);
return PopupMenuItem(
value: e.index,
child: Text(str),
);
},
).toList();
final items = ThemeMode.values
.map(
(e) => PopupMenuItem(
value: e.index,
child: Text(_buildThemeModeStr(e.index)),
),
)
.toList();
// Issue #57
final len = ThemeMode.values.length;
items.add(PopupMenuItem(value: len, child: Text(_buildThemeModeStr(len))));
return ListTile(
title: Text(
@@ -406,6 +408,8 @@ class _SettingPageState extends State<SettingPage> {
return _s.light;
case 2:
return _s.dark;
case 3:
return 'AMOLED';
default:
return _s.auto;
}

View File

@@ -66,8 +66,16 @@ class TagEditor extends StatelessWidget {
Widget _buildTagItem(BuildContext context, String tag, bool isAdd) {
return Padding(
padding: const EdgeInsets.symmetric(horizontal: 3),
child: GestureDetector(
onTap: () => _showRenameDialog(context, tag),
child: InkWell(
onTap: () {
if (isAdd) {
tags.add(tag);
} else {
tags.remove(tag);
}
onChanged?.call(tags);
},
onLongPress: () => _showRenameDialog(context, tag),
child: Container(
decoration: BoxDecoration(
borderRadius: const BorderRadius.all(Radius.circular(20.0)),
@@ -82,21 +90,11 @@ class TagEditor extends StatelessWidget {
style: const TextStyle(color: Colors.white),
),
const SizedBox(width: 4.0),
InkWell(
child: Icon(
isAdd ? Icons.add_circle : Icons.cancel,
size: 14.0,
color: Colors.white,
),
onTap: () {
if (isAdd) {
tags.add(tag);
} else {
tags.remove(tag);
}
onChanged?.call(tags);
},
)
Icon(
isAdd ? Icons.add_circle : Icons.cancel,
size: 14.0,
color: Colors.white,
),
],
),
),