wip: fix localization issues.
This commit is contained in:
@@ -14,6 +14,8 @@ import 'pages/home.dart';
|
||||
|
||||
Future<void> main() async {
|
||||
WidgetsFlutterBinding.ensureInitialized();
|
||||
EasyLocalization.logger.enableLevels = [];
|
||||
await EasyLocalization.ensureInitialized();
|
||||
await initConfigs();
|
||||
runApp(EasyLocalization(
|
||||
supportedLocales: [
|
||||
@@ -47,6 +49,9 @@ class MyApp extends StatelessWidget {
|
||||
return MaterialApp(
|
||||
title: 'Flutter Demo',
|
||||
theme: showDarkMode ? darkTheme : lightTheme,
|
||||
localizationsDelegates: context.localizationDelegates,
|
||||
supportedLocales: context.supportedLocales,
|
||||
locale: context.locale,
|
||||
home: AnimatedCrossFade(
|
||||
crossFadeState: isDarkMode != null ? CrossFadeState.showSecond : CrossFadeState.showFirst,
|
||||
alignment: Alignment.center,
|
||||
|
||||
@@ -23,7 +23,7 @@ class _HomePageState extends State<HomePage> {
|
||||
],
|
||||
),
|
||||
SizedBox(
|
||||
height: 32,
|
||||
height: 36,
|
||||
child: Footer(),
|
||||
),
|
||||
],
|
||||
|
||||
@@ -1,5 +1,6 @@
|
||||
import 'package:dde_gesture_manager/models/configs.dart';
|
||||
import 'package:dde_gesture_manager/models/configs.provider.dart';
|
||||
import 'package:flutter/cupertino.dart';
|
||||
import 'package:flutter/material.dart';
|
||||
import 'package:dde_gesture_manager/extensions.dart';
|
||||
|
||||
@@ -13,28 +14,47 @@ class Footer extends StatefulWidget {
|
||||
class _FooterState extends State<Footer> {
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
var _brightnessMode = context.watch<ConfigsProvider>().brightnessMode;
|
||||
return Container(
|
||||
color: context.t.backgroundColor,
|
||||
child: Padding(
|
||||
padding: EdgeInsets.symmetric(horizontal: 12),
|
||||
child: Row(
|
||||
mainAxisAlignment: MainAxisAlignment.spaceBetween,
|
||||
crossAxisAlignment: CrossAxisAlignment.center,
|
||||
children: [
|
||||
Container(),
|
||||
PopupMenuButton(
|
||||
initialValue: context.watch<ConfigsProvider>().brightnessMode,
|
||||
child: Icon(Icons.brightness_4_outlined),
|
||||
initialValue: _brightnessMode,
|
||||
icon: Icon(Icons.brightness_4_outlined),
|
||||
tooltip: LocaleKeys.theme_label.tr(),
|
||||
itemBuilder: (BuildContext context) => [
|
||||
PopupMenuItem<BrightnessMode>(
|
||||
child: Text(LocaleKeys.theme_label).tr(),
|
||||
child: ListTile(
|
||||
leading: Visibility(
|
||||
child: Icon(CupertinoIcons.check_mark),
|
||||
visible: _brightnessMode == BrightnessMode.system,
|
||||
),
|
||||
title: Text(LocaleKeys.theme_system).tr(),
|
||||
),
|
||||
onTap: () => context.read<ConfigsProvider>().setProps(brightnessMode: BrightnessMode.system),
|
||||
),
|
||||
PopupMenuItem<BrightnessMode>(
|
||||
child: Text(LocaleKeys.theme_light).tr(),
|
||||
child: ListTile(
|
||||
leading: Visibility(
|
||||
child: Icon(CupertinoIcons.check_mark),
|
||||
visible: _brightnessMode == BrightnessMode.light,
|
||||
),
|
||||
title: Text(LocaleKeys.theme_light).tr()),
|
||||
onTap: () => context.read<ConfigsProvider>().setProps(brightnessMode: BrightnessMode.light),
|
||||
),
|
||||
PopupMenuItem<BrightnessMode>(
|
||||
child: Text(LocaleKeys.theme_dark).tr(),
|
||||
child: ListTile(
|
||||
leading: Visibility(
|
||||
child: Icon(CupertinoIcons.check_mark),
|
||||
visible: _brightnessMode == BrightnessMode.dark,
|
||||
),
|
||||
title: Text(LocaleKeys.theme_dark).tr()),
|
||||
onTap: () => context.read<ConfigsProvider>().setProps(brightnessMode: BrightnessMode.dark),
|
||||
),
|
||||
],
|
||||
|
||||
@@ -0,0 +1,6 @@
|
||||
#!/usr/bin/env bash
|
||||
|
||||
flutter packages pub get
|
||||
flutter packages pub run build_runner build --delete-conflicting-outputs
|
||||
flutter pub run easy_localization:generate
|
||||
flutter pub run easy_localization:generate -f keys -o locale_keys.g.dart
|
||||
Reference in New Issue
Block a user