refactor: Update to Dart 3.10 with . shorthands
This commit is contained in:
parent
75a37f3f7c
commit
1ea649f01e
167 changed files with 3351 additions and 3912 deletions
|
|
@ -43,18 +43,16 @@ abstract class AppRoutes {
|
|||
static FutureOr<String?> loggedInRedirect(
|
||||
BuildContext context,
|
||||
GoRouterState state,
|
||||
) =>
|
||||
Matrix.of(context).widget.clients.any((client) => client.isLogged())
|
||||
? '/rooms'
|
||||
: null;
|
||||
) => Matrix.of(context).widget.clients.any((client) => client.isLogged())
|
||||
? '/rooms'
|
||||
: null;
|
||||
|
||||
static FutureOr<String?> loggedOutRedirect(
|
||||
BuildContext context,
|
||||
GoRouterState state,
|
||||
) =>
|
||||
Matrix.of(context).widget.clients.any((client) => client.isLogged())
|
||||
? null
|
||||
: '/home';
|
||||
) => Matrix.of(context).widget.clients.any((client) => client.isLogged())
|
||||
? null
|
||||
: '/home';
|
||||
|
||||
AppRoutes();
|
||||
|
||||
|
|
@ -63,8 +61,8 @@ abstract class AppRoutes {
|
|||
path: '/',
|
||||
redirect: (context, state) =>
|
||||
Matrix.of(context).widget.clients.any((client) => client.isLogged())
|
||||
? '/rooms'
|
||||
: '/home',
|
||||
? '/rooms'
|
||||
: '/home',
|
||||
),
|
||||
GoRoute(
|
||||
path: '/home',
|
||||
|
|
@ -88,19 +86,13 @@ abstract class AppRoutes {
|
|||
),
|
||||
GoRoute(
|
||||
path: '/logs',
|
||||
pageBuilder: (context, state) => defaultPageBuilder(
|
||||
context,
|
||||
state,
|
||||
const LogViewer(),
|
||||
),
|
||||
pageBuilder: (context, state) =>
|
||||
defaultPageBuilder(context, state, const LogViewer()),
|
||||
),
|
||||
GoRoute(
|
||||
path: '/configs',
|
||||
pageBuilder: (context, state) => defaultPageBuilder(
|
||||
context,
|
||||
state,
|
||||
const ConfigViewer(),
|
||||
),
|
||||
pageBuilder: (context, state) =>
|
||||
defaultPageBuilder(context, state, const ConfigViewer()),
|
||||
),
|
||||
GoRoute(
|
||||
path: '/backup',
|
||||
|
|
@ -108,9 +100,7 @@ abstract class AppRoutes {
|
|||
pageBuilder: (context, state) => defaultPageBuilder(
|
||||
context,
|
||||
state,
|
||||
BootstrapDialog(
|
||||
wipe: state.uri.queryParameters['wipe'] == 'true',
|
||||
),
|
||||
BootstrapDialog(wipe: state.uri.queryParameters['wipe'] == 'true'),
|
||||
),
|
||||
),
|
||||
ShellRoute(
|
||||
|
|
@ -150,11 +140,8 @@ abstract class AppRoutes {
|
|||
routes: [
|
||||
GoRoute(
|
||||
path: 'archive',
|
||||
pageBuilder: (context, state) => defaultPageBuilder(
|
||||
context,
|
||||
state,
|
||||
const Archive(),
|
||||
),
|
||||
pageBuilder: (context, state) =>
|
||||
defaultPageBuilder(context, state, const Archive()),
|
||||
routes: [
|
||||
GoRoute(
|
||||
path: ':roomid',
|
||||
|
|
@ -173,20 +160,14 @@ abstract class AppRoutes {
|
|||
),
|
||||
GoRoute(
|
||||
path: 'newprivatechat',
|
||||
pageBuilder: (context, state) => defaultPageBuilder(
|
||||
context,
|
||||
state,
|
||||
const NewPrivateChat(),
|
||||
),
|
||||
pageBuilder: (context, state) =>
|
||||
defaultPageBuilder(context, state, const NewPrivateChat()),
|
||||
redirect: loggedOutRedirect,
|
||||
),
|
||||
GoRoute(
|
||||
path: 'newgroup',
|
||||
pageBuilder: (context, state) => defaultPageBuilder(
|
||||
context,
|
||||
state,
|
||||
const NewGroup(),
|
||||
),
|
||||
pageBuilder: (context, state) =>
|
||||
defaultPageBuilder(context, state, const NewGroup()),
|
||||
redirect: loggedOutRedirect,
|
||||
),
|
||||
GoRoute(
|
||||
|
|
@ -376,9 +357,7 @@ abstract class AppRoutes {
|
|||
pageBuilder: (context, state) => defaultPageBuilder(
|
||||
context,
|
||||
state,
|
||||
ChatSearchPage(
|
||||
roomId: state.pathParameters['roomid']!,
|
||||
),
|
||||
ChatSearchPage(roomId: state.pathParameters['roomid']!),
|
||||
),
|
||||
redirect: loggedOutRedirect,
|
||||
),
|
||||
|
|
@ -407,9 +386,7 @@ abstract class AppRoutes {
|
|||
pageBuilder: (context, state) => defaultPageBuilder(
|
||||
context,
|
||||
state,
|
||||
ChatDetails(
|
||||
roomId: state.pathParameters['roomid']!,
|
||||
),
|
||||
ChatDetails(roomId: state.pathParameters['roomid']!),
|
||||
),
|
||||
routes: [
|
||||
GoRoute(
|
||||
|
|
@ -459,9 +436,7 @@ abstract class AppRoutes {
|
|||
pageBuilder: (context, state) => defaultPageBuilder(
|
||||
context,
|
||||
state,
|
||||
EmotesSettings(
|
||||
roomId: state.pathParameters['roomid'],
|
||||
),
|
||||
EmotesSettings(roomId: state.pathParameters['roomid']),
|
||||
),
|
||||
redirect: loggedOutRedirect,
|
||||
),
|
||||
|
|
@ -480,23 +455,21 @@ abstract class AppRoutes {
|
|||
BuildContext context,
|
||||
GoRouterState state,
|
||||
Widget child,
|
||||
) =>
|
||||
NoTransitionPage(
|
||||
key: state.pageKey,
|
||||
restorationId: state.pageKey.value,
|
||||
child: child,
|
||||
);
|
||||
) => NoTransitionPage(
|
||||
key: state.pageKey,
|
||||
restorationId: state.pageKey.value,
|
||||
child: child,
|
||||
);
|
||||
|
||||
static Page defaultPageBuilder(
|
||||
BuildContext context,
|
||||
GoRouterState state,
|
||||
Widget child,
|
||||
) =>
|
||||
FluffyThemes.isColumnMode(context)
|
||||
? noTransitionPageBuilder(context, state, child)
|
||||
: MaterialPage(
|
||||
key: state.pageKey,
|
||||
restorationId: state.pageKey.value,
|
||||
child: child,
|
||||
);
|
||||
) => FluffyThemes.isColumnMode(context)
|
||||
? noTransitionPageBuilder(context, state, child)
|
||||
: MaterialPage(
|
||||
key: state.pageKey,
|
||||
restorationId: state.pageKey.value,
|
||||
child: child,
|
||||
);
|
||||
}
|
||||
|
|
|
|||
|
|
@ -46,18 +46,12 @@ enum AppSettings<T> {
|
|||
'chat.fluffy.no_encryption_warning_shown',
|
||||
false,
|
||||
),
|
||||
displayChatDetailsColumn(
|
||||
'chat.fluffy.display_chat_details_column',
|
||||
false,
|
||||
),
|
||||
displayChatDetailsColumn('chat.fluffy.display_chat_details_column', false),
|
||||
// AppConfig-mirrored settings
|
||||
applicationName<String>('chat.fluffy.application_name', 'FluffyChat'),
|
||||
defaultHomeserver<String>('chat.fluffy.default_homeserver', 'matrix.org'),
|
||||
// colorSchemeSeed stored as ARGB int
|
||||
colorSchemeSeedInt<int>(
|
||||
'chat.fluffy.color_scheme_seed',
|
||||
0xFF5625BA,
|
||||
),
|
||||
colorSchemeSeedInt<int>('chat.fluffy.color_scheme_seed', 0xFF5625BA),
|
||||
emojiSuggestionLocale<String>('emoji_suggestion_locale', ''),
|
||||
enableSoftLogout<bool>('chat.fluffy.enable_soft_logout', false);
|
||||
|
||||
|
|
@ -75,10 +69,9 @@ enum AppSettings<T> {
|
|||
final store = AppSettings._store = await SharedPreferences.getInstance();
|
||||
|
||||
// Migrate wrong datatype for fontSizeFactor
|
||||
final fontSizeFactorString =
|
||||
Result(() => store.getString(AppSettings.fontSizeFactor.key))
|
||||
.asValue
|
||||
?.value;
|
||||
final fontSizeFactorString = Result(
|
||||
() => store.getString(AppSettings.fontSizeFactor.key),
|
||||
).asValue?.value;
|
||||
if (fontSizeFactorString != null) {
|
||||
Logs().i('Migrate wrong datatype for fontSizeFactor!');
|
||||
await store.remove(AppSettings.fontSizeFactor.key);
|
||||
|
|
@ -93,8 +86,9 @@ enum AppSettings<T> {
|
|||
}
|
||||
if (kIsWeb && loadWebConfigFile) {
|
||||
try {
|
||||
final configJsonString =
|
||||
utf8.decode((await http.get(Uri.parse('config.json'))).bodyBytes);
|
||||
final configJsonString = utf8.decode(
|
||||
(await http.get(Uri.parse('config.json'))).bodyBytes,
|
||||
);
|
||||
final configJson =
|
||||
json.decode(configJsonString) as Map<String, Object?>;
|
||||
for (final setting in AppSettings.values) {
|
||||
|
|
|
|||
|
|
@ -20,10 +20,7 @@ abstract class FluffyThemes {
|
|||
static bool isThreeColumnMode(BuildContext context) =>
|
||||
MediaQuery.sizeOf(context).width > FluffyThemes.columnWidth * 3.5;
|
||||
|
||||
static LinearGradient backgroundGradient(
|
||||
BuildContext context,
|
||||
int alpha,
|
||||
) {
|
||||
static LinearGradient backgroundGradient(BuildContext context, int alpha) {
|
||||
final colorScheme = Theme.of(context).colorScheme;
|
||||
return LinearGradient(
|
||||
begin: Alignment.topCenter,
|
||||
|
|
@ -91,12 +88,14 @@ abstract class FluffyThemes {
|
|||
),
|
||||
appBarTheme: AppBarTheme(
|
||||
toolbarHeight: isColumnMode ? 72 : 56,
|
||||
shadowColor:
|
||||
isColumnMode ? colorScheme.surfaceContainer.withAlpha(128) : null,
|
||||
shadowColor: isColumnMode
|
||||
? colorScheme.surfaceContainer.withAlpha(128)
|
||||
: null,
|
||||
surfaceTintColor: isColumnMode ? colorScheme.surface : null,
|
||||
backgroundColor: isColumnMode ? colorScheme.surface : null,
|
||||
actionsPadding:
|
||||
isColumnMode ? const EdgeInsets.symmetric(horizontal: 16.0) : null,
|
||||
actionsPadding: isColumnMode
|
||||
? const EdgeInsets.symmetric(horizontal: 16.0)
|
||||
: null,
|
||||
systemOverlayStyle: SystemUiOverlayStyle(
|
||||
statusBarColor: Colors.transparent,
|
||||
statusBarIconBrightness: brightness.reversed,
|
||||
|
|
@ -107,10 +106,7 @@ abstract class FluffyThemes {
|
|||
),
|
||||
outlinedButtonTheme: OutlinedButtonThemeData(
|
||||
style: OutlinedButton.styleFrom(
|
||||
side: BorderSide(
|
||||
width: 1,
|
||||
color: colorScheme.primary,
|
||||
),
|
||||
side: BorderSide(width: 1, color: colorScheme.primary),
|
||||
shape: RoundedRectangleBorder(
|
||||
side: BorderSide(color: colorScheme.primary),
|
||||
borderRadius: BorderRadius.circular(AppConfig.borderRadius / 2),
|
||||
|
|
@ -157,8 +153,8 @@ extension BubbleColorTheme on ThemeData {
|
|||
: colorScheme.onPrimaryContainer;
|
||||
|
||||
Color get secondaryBubbleColor => HSLColor.fromColor(
|
||||
brightness == Brightness.light
|
||||
? colorScheme.tertiary
|
||||
: colorScheme.tertiaryContainer,
|
||||
).withSaturation(0.5).toColor();
|
||||
brightness == Brightness.light
|
||||
? colorScheme.tertiary
|
||||
: colorScheme.tertiaryContainer,
|
||||
).withSaturation(0.5).toColor();
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue