From d7972c4084b7c7c7a4a87b56a202715f8358a59a Mon Sep 17 00:00:00 2001 From: Rongjian Zhang Date: Mon, 26 Sep 2022 01:32:51 +0800 Subject: [PATCH] chore: settings style tweaks --- lib/screens/code_theme.dart | 34 ++++--- lib/screens/settings.dart | 181 ++++++++++++++++++------------------ 2 files changed, 112 insertions(+), 103 deletions(-) diff --git a/lib/screens/code_theme.dart b/lib/screens/code_theme.dart index c0aba69..9121700 100644 --- a/lib/screens/code_theme.dart +++ b/lib/screens/code_theme.dart @@ -45,6 +45,7 @@ class MyApp extends StatelessWidget { children: [ CommonStyle.verticalGap, AntList( + mode: AntListMode.card, header: Text(AppLocalizations.of(context)!.fontStyle), children: [ AntListItem( @@ -88,6 +89,7 @@ class MyApp extends StatelessWidget { ), CommonStyle.verticalGap, AntList( + mode: AntListMode.card, header: Text(AppLocalizations.of(context)!.syntaxHighlighting), children: [ AntListItem( @@ -108,6 +110,15 @@ class MyApp extends StatelessWidget { }, child: Text(AppLocalizations.of(context)!.light), ), + AntListItem( + child: HighlightView( + _getCode(false), + language: 'dart', + theme: themeMap[codeProvider.theme]!, + textStyle: codeProvider.fontStyle, + padding: CommonStyle.padding, + ), + ), AntListItem( extra: Text(codeProvider.themeDark), onClick: () { @@ -126,22 +137,17 @@ class MyApp extends StatelessWidget { }, child: Text(AppLocalizations.of(context)!.dark), ), + AntListItem( + child: HighlightView( + _getCode(true), + language: 'dart', + theme: themeMap[codeProvider.themeDark]!, + textStyle: codeProvider.fontStyle, + padding: CommonStyle.padding, + ), + ) ], ), - HighlightView( - _getCode(false), - language: 'dart', - theme: themeMap[codeProvider.theme]!, - textStyle: codeProvider.fontStyle, - padding: CommonStyle.padding, - ), - HighlightView( - _getCode(true), - language: 'dart', - theme: themeMap[codeProvider.themeDark]!, - textStyle: codeProvider.fontStyle, - padding: CommonStyle.padding, - ), ], ), ); diff --git a/lib/screens/settings.dart b/lib/screens/settings.dart index 79a8dc6..7e38537 100644 --- a/lib/screens/settings.dart +++ b/lib/screens/settings.dart @@ -28,104 +28,105 @@ class SettingsScreen extends StatelessWidget { children: [ CommonStyle.verticalGap, AntList( - header: Text(AppLocalizations.of(context)!.system), - children: [ - if (auth.activeAccount!.platform == PlatformType.github) ...[ - AntListItem( - child: Text(AppLocalizations.of(context)!.githubStatus), - onClick: () { - launchStringUrl('https://www.githubstatus.com/'); - }, - ), - AntListItem( - child: const Text('Meta'), - onClick: () { - context.push('/settings/github-meta'); - }, - ), - AntListItem( - onClick: () { - launchStringUrl( - 'https://github.com/settings/connections/applications/$clientId'); - }, - extra: Text(auth.activeAccount!.login), - child: - Text(AppLocalizations.of(context)!.reviewPermissions), - ), - ], - if (auth.activeAccount!.platform == PlatformType.gitlab) - AntListItem( - onClick: () { - launchStringUrl('${auth.activeAccount!.domain}/help'); - }, - extra: FutureBuilder( - future: auth - .fetchGitlab('/version') - .then((v) => v['version']), - builder: (context, snapshot) { - return Text(snapshot.data ?? ''); - }, - ), - child: Text(AppLocalizations.of(context)!.gitlabStatus), - ), - if (auth.activeAccount!.platform == PlatformType.gitea) - AntListItem( - prefix: const Icon(Octicons.info), - onClick: () { - context.push('/gitea/status'); - }, - extra: FutureBuilder( - future: - auth.fetchGitea('/version').then((v) => v['version']), - builder: (context, snapshot) { - return Text(snapshot.data ?? ''); - }, - ), - child: Text(AppLocalizations.of(context)!.giteaStatus), - ), + mode: AntListMode.card, + header: Text(AppLocalizations.of(context)!.system), + children: [ + if (auth.activeAccount!.platform == PlatformType.github) ...[ AntListItem( + child: Text(AppLocalizations.of(context)!.githubStatus), onClick: () { - context.push('/login'); + launchStringUrl('https://www.githubstatus.com/'); }, - extra: Text(auth.activeAccount!.login), - child: Text(AppLocalizations.of(context)!.switchAccounts), ), AntListItem( - extra: Text(theme.locale == null - ? AppLocalizations.of(context)!.followSystem - : localeNameMap[theme.locale!] ?? theme.locale!), + child: const Text('Meta'), onClick: () { - // TODO: too many options, better use a new page - theme.showActions(context, [ - for (final key in [ - null, - ...AppLocalizations.supportedLocales - .map((l) => l.toString()) - .where((key) => localeNameMap[key] != null) - ]) - ActionItem( - text: key == null - ? AppLocalizations.of(context)!.followSystem - : localeNameMap[key], - onTap: (_) async { - final res = await theme.showConfirm( - context, - const Text( - 'The app will reload to make the language setting take effect'), - ); - if (res == true && theme.locale != key) { - await theme.setLocale(key); - auth.reloadApp(); - } - }, - ) - ]); + context.push('/settings/github-meta'); }, - child: Text(AppLocalizations.of(context)!.appLanguage), - ) - ]), + ), + AntListItem( + onClick: () { + launchStringUrl( + 'https://github.com/settings/connections/applications/$clientId'); + }, + extra: Text(auth.activeAccount!.login), + child: Text(AppLocalizations.of(context)!.reviewPermissions), + ), + ], + if (auth.activeAccount!.platform == PlatformType.gitlab) + AntListItem( + onClick: () { + launchStringUrl('${auth.activeAccount!.domain}/help'); + }, + extra: FutureBuilder( + future: + auth.fetchGitlab('/version').then((v) => v['version']), + builder: (context, snapshot) { + return Text(snapshot.data ?? ''); + }, + ), + child: Text(AppLocalizations.of(context)!.gitlabStatus), + ), + if (auth.activeAccount!.platform == PlatformType.gitea) + AntListItem( + prefix: const Icon(Octicons.info), + onClick: () { + context.push('/gitea/status'); + }, + extra: FutureBuilder( + future: + auth.fetchGitea('/version').then((v) => v['version']), + builder: (context, snapshot) { + return Text(snapshot.data ?? ''); + }, + ), + child: Text(AppLocalizations.of(context)!.giteaStatus), + ), + AntListItem( + onClick: () { + context.push('/login'); + }, + extra: Text(auth.activeAccount!.login), + child: Text(AppLocalizations.of(context)!.switchAccounts), + ), + AntListItem( + extra: Text(theme.locale == null + ? AppLocalizations.of(context)!.followSystem + : localeNameMap[theme.locale!] ?? theme.locale!), + onClick: () { + // TODO: too many options, better use a new page + theme.showActions(context, [ + for (final key in [ + null, + ...AppLocalizations.supportedLocales + .map((l) => l.toString()) + .where((key) => localeNameMap[key] != null) + ]) + ActionItem( + text: key == null + ? AppLocalizations.of(context)!.followSystem + : localeNameMap[key], + onTap: (_) async { + final res = await theme.showConfirm( + context, + const Text( + 'The app will reload to make the language setting take effect'), + ); + if (res == true && theme.locale != key) { + await theme.setLocale(key); + auth.reloadApp(); + } + }, + ) + ]); + }, + child: Text(AppLocalizations.of(context)!.appLanguage), + ) + ], + ), CommonStyle.verticalGap, AntList( + mode: AntListMode.card, header: Text(AppLocalizations.of(context)!.theme), children: [ AntListItem( @@ -191,6 +192,7 @@ class SettingsScreen extends StatelessWidget { ), CommonStyle.verticalGap, AntList( + mode: AntListMode.card, header: Text(AppLocalizations.of(context)!.feedback), children: [ AntListItem( @@ -226,6 +228,7 @@ class SettingsScreen extends StatelessWidget { ), CommonStyle.verticalGap, AntList( + mode: AntListMode.card, header: Text(AppLocalizations.of(context)!.about), children: [ AntListItem(