From f0f1e8cacce0d63dfb05a3346d691ac8d473140f Mon Sep 17 00:00:00 2001 From: Inex Code Date: Mon, 27 Mar 2023 20:02:44 +0300 Subject: [PATCH] refactor(ui): Get rid of BrandText and restructure the buttons --- lib/config/brand_colors.dart | 37 --- lib/config/text_themes.dart | 80 ------ lib/logic/get_it/navigation.dart | 5 +- .../brand_bottom_sheet.dart | 3 +- lib/ui/components/brand_md/brand_md.dart | 21 +- .../components/brand_radio/brand_radio.dart | 40 --- lib/ui/components/brand_text/brand_text.dart | 238 ------------------ .../components/brand_timer/brand_timer.dart | 12 +- .../brand_button.dart | 52 ---- .../dialog_action_button.dart} | 5 +- .../outlined_button.dart | 0 .../segmented_buttons.dart | 21 +- .../components/jobs_content/jobs_content.dart | 13 +- .../components/progress_bar/progress_bar.dart | 13 +- .../components/switch_block/switch_bloc.dart | 36 --- lib/ui/helpers/modals.dart | 6 +- .../pages/backup_details/backup_details.dart | 13 +- lib/ui/pages/devices/new_device.dart | 2 +- lib/ui/pages/more/about_application.dart | 7 +- .../pages/more/app_settings/app_settings.dart | 10 +- lib/ui/pages/more/console.dart | 7 +- lib/ui/pages/onboarding/onboarding.dart | 2 +- lib/ui/pages/recovery_key/recovery_key.dart | 2 +- .../recovery_key/recovery_key_receiving.dart | 2 +- .../server_details/server_details_screen.dart | 6 +- lib/ui/pages/server_details/text_details.dart | 39 +-- .../server_details/time_zone/time_zone.dart | 167 ++++++------ .../migration_process_page.dart | 2 +- .../binds_migration/services_migration.dart | 2 +- .../server_storage/extending_volume.dart | 2 +- .../pages/server_storage/server_storage.dart | 2 +- lib/ui/pages/services/services.dart | 101 +++++--- .../setup/initializing/initializing.dart | 16 +- .../initializing/server_provider_picker.dart | 4 +- .../initializing/server_type_picker.dart | 2 +- .../recovering/recover_by_new_device_key.dart | 2 +- .../recovering/recover_by_old_token.dart | 2 +- .../recovering/recover_by_recovery_key.dart | 2 +- .../recovery_confirm_backblaze.dart | 2 +- .../recovery_confirm_cloudflare.dart | 2 +- .../recovering/recovery_confirm_server.dart | 2 +- .../recovering/recovery_method_select.dart | 2 +- .../setup/recovering/recovery_routing.dart | 2 +- .../recovery_server_provider_connected.dart | 2 +- lib/ui/pages/users/empty.dart | 44 ++-- lib/ui/pages/users/user.dart | 20 +- lib/ui/pages/users/users.dart | 5 +- lib/utils/extensions/text_extensions.dart | 2 +- 48 files changed, 297 insertions(+), 762 deletions(-) delete mode 100644 lib/config/text_themes.dart delete mode 100644 lib/ui/components/brand_radio/brand_radio.dart delete mode 100644 lib/ui/components/brand_text/brand_text.dart rename lib/ui/components/{brand_button => buttons}/brand_button.dart (54%) rename lib/ui/components/{action_button/action_button.dart => buttons/dialog_action_button.dart} (81%) rename lib/ui/components/{brand_button => buttons}/outlined_button.dart (100%) rename lib/ui/components/{brand_button => buttons}/segmented_buttons.dart (70%) delete mode 100644 lib/ui/components/switch_block/switch_bloc.dart diff --git a/lib/config/brand_colors.dart b/lib/config/brand_colors.dart index 15d1433a..335e652e 100644 --- a/lib/config/brand_colors.dart +++ b/lib/config/brand_colors.dart @@ -2,53 +2,16 @@ import 'package:flutter/material.dart'; class BrandColors { static const Color blue = Color(0xFF093CEF); - static const Color white = Colors.white; - static const Color black = Colors.black; - - static const Color gray1 = Color(0xFF555555); - static const Color gray2 = Color(0xFF7C7C7C); - static const Color gray3 = Color(0xFFFAFAFA); - static const Color gray4 = Color(0xFFDDDDDD); - static const Color gray5 = Color(0xFFEDEEF1); - static Color gray6 = const Color(0xFF181818).withOpacity(0.7); - static const Color grey7 = Color(0xFFABABAB); - - static const Color red1 = Color(0xFFFA0E0E); - static const Color red2 = Color(0xFFE65527); - - static const Color green1 = Color(0xFF00AF54); - - static const Color green2 = Color(0xFF0F8849); - - static Color get navBackgroundLight => white.withOpacity(0.8); - static Color get navBackgroundDark => black.withOpacity(0.8); static const List uninitializedGradientColors = [ Color(0xFF555555), Color(0xFFABABAB), ]; - static const List stableGradientColors = [ - Color(0xFF093CEF), - Color(0xFF14A1CB), - ]; - static const List progressGradientColors = [ - Color(0xFF093CEF), - Color(0xFF14A1CB), - ]; static const List warningGradientColors = [ Color(0xFFEF4E09), Color(0xFFEFD135), ]; static const Color primary = blue; - static const Color headlineColor = black; - static const Color inactive = gray2; - static const Color scaffoldBackground = gray3; - static const Color inputInactive = gray4; - - static const Color textColor1 = black; - static const Color textColor2 = gray1; - static const Color dividerColor = gray5; - static const Color warning = red1; } diff --git a/lib/config/text_themes.dart b/lib/config/text_themes.dart deleted file mode 100644 index 63b4b99c..00000000 --- a/lib/config/text_themes.dart +++ /dev/null @@ -1,80 +0,0 @@ -import 'package:flutter/material.dart'; -import 'package:selfprivacy/utils/named_font_weight.dart'; - -import 'package:selfprivacy/config/brand_colors.dart'; - -const TextStyle defaultTextStyle = TextStyle( - fontSize: 15, - color: BrandColors.textColor1, -); - -final TextStyle headline1Style = defaultTextStyle.copyWith( - fontSize: 40, - fontWeight: NamedFontWeight.extraBold, - color: BrandColors.headlineColor, -); - -final TextStyle headline2Style = defaultTextStyle.copyWith( - fontSize: 24, - fontWeight: NamedFontWeight.extraBold, - color: BrandColors.headlineColor, -); - -final TextStyle onboardingTitle = defaultTextStyle.copyWith( - fontSize: 30, - fontWeight: NamedFontWeight.extraBold, - color: BrandColors.headlineColor, -); - -final TextStyle headline3Style = defaultTextStyle.copyWith( - fontSize: 20, - fontWeight: NamedFontWeight.extraBold, - color: BrandColors.headlineColor, -); - -final TextStyle headline4Style = defaultTextStyle.copyWith( - fontSize: 18, - fontWeight: NamedFontWeight.medium, - color: BrandColors.headlineColor, -); - -final TextStyle headline4UnderlinedStyle = defaultTextStyle.copyWith( - fontSize: 18, - fontWeight: NamedFontWeight.medium, - color: BrandColors.headlineColor, - decoration: TextDecoration.underline, -); - -final TextStyle headline5Style = defaultTextStyle.copyWith( - fontSize: 15, - fontWeight: NamedFontWeight.medium, - color: BrandColors.headlineColor.withOpacity(0.8), -); - -const TextStyle body1Style = defaultTextStyle; -final TextStyle body2Style = defaultTextStyle.copyWith( - color: BrandColors.textColor2, -); - -final TextStyle buttonTitleText = defaultTextStyle.copyWith( - color: BrandColors.white, - fontSize: 16, - fontWeight: FontWeight.bold, - height: 1, -); - -final TextStyle mediumStyle = - defaultTextStyle.copyWith(fontSize: 13, height: 1.53); - -final TextStyle smallStyle = - defaultTextStyle.copyWith(fontSize: 11, height: 1.45); - -const TextStyle progressTextStyleLight = TextStyle( - fontSize: 11, - color: BrandColors.textColor1, - height: 1.7, -); - -final TextStyle progressTextStyleDark = progressTextStyleLight.copyWith( - color: BrandColors.white, -); diff --git a/lib/logic/get_it/navigation.dart b/lib/logic/get_it/navigation.dart index 977b4a86..90f67203 100644 --- a/lib/logic/get_it/navigation.dart +++ b/lib/logic/get_it/navigation.dart @@ -1,6 +1,4 @@ import 'package:flutter/material.dart'; -import 'package:selfprivacy/config/brand_colors.dart'; -import 'package:selfprivacy/config/text_themes.dart'; class NavigationService { final GlobalKey scaffoldMessengerKey = @@ -26,8 +24,7 @@ class NavigationService { void showSnackBar(final String text) { final ScaffoldMessengerState state = scaffoldMessengerKey.currentState!; final SnackBar snack = SnackBar( - backgroundColor: BrandColors.black.withOpacity(0.8), - content: Text(text, style: buttonTitleText), + content: Text(text), duration: const Duration(seconds: 2), ); state.showSnackBar(snack); diff --git a/lib/ui/components/brand_bottom_sheet/brand_bottom_sheet.dart b/lib/ui/components/brand_bottom_sheet/brand_bottom_sheet.dart index d53b5ced..420ba32b 100644 --- a/lib/ui/components/brand_bottom_sheet/brand_bottom_sheet.dart +++ b/lib/ui/components/brand_bottom_sheet/brand_bottom_sheet.dart @@ -1,5 +1,4 @@ import 'package:flutter/material.dart'; -import 'package:selfprivacy/config/brand_colors.dart'; class BrandBottomSheet extends StatelessWidget { const BrandBottomSheet({ @@ -38,7 +37,7 @@ class BrandBottomSheet extends StatelessWidget { width: 30, decoration: BoxDecoration( borderRadius: BorderRadius.circular(2), - color: BrandColors.gray4, + color: const Color(0xFFDDDDDD), ), ), ), diff --git a/lib/ui/components/brand_md/brand_md.dart b/lib/ui/components/brand_md/brand_md.dart index 457bb5c3..67c3e2ea 100644 --- a/lib/ui/components/brand_md/brand_md.dart +++ b/lib/ui/components/brand_md/brand_md.dart @@ -2,8 +2,6 @@ import 'package:flutter/material.dart'; import 'package:flutter_markdown/flutter_markdown.dart'; import 'package:flutter/services.dart' show rootBundle; import 'package:easy_localization/easy_localization.dart'; -import 'package:selfprivacy/config/brand_colors.dart'; -import 'package:selfprivacy/config/text_themes.dart'; import 'package:url_launcher/url_launcher_string.dart'; class BrandMarkdown extends StatefulWidget { @@ -37,24 +35,7 @@ class _BrandMarkdownState extends State { @override Widget build(final BuildContext context) { - final bool isDark = Theme.of(context).brightness == Brightness.dark; - final MarkdownStyleSheet markdown = MarkdownStyleSheet( - p: defaultTextStyle.copyWith( - color: isDark ? BrandColors.white : null, - ), - h1: headline1Style.copyWith( - color: isDark ? BrandColors.white : null, - ), - h2: headline2Style.copyWith( - color: isDark ? BrandColors.white : null, - ), - h3: headline3Style.copyWith( - color: isDark ? BrandColors.white : null, - ), - h4: headline4Style.copyWith( - color: isDark ? BrandColors.white : null, - ), - ); + final MarkdownStyleSheet markdown = MarkdownStyleSheet(); return MarkdownBody( shrinkWrap: true, styleSheet: markdown, diff --git a/lib/ui/components/brand_radio/brand_radio.dart b/lib/ui/components/brand_radio/brand_radio.dart deleted file mode 100644 index 494c3e81..00000000 --- a/lib/ui/components/brand_radio/brand_radio.dart +++ /dev/null @@ -1,40 +0,0 @@ -import 'package:flutter/material.dart'; -import 'package:selfprivacy/config/brand_colors.dart'; - -// TODO: Delete this file. - -class BrandRadio extends StatelessWidget { - const BrandRadio({ - required this.isChecked, - super.key, - }); - - final bool isChecked; - - @override - Widget build(final BuildContext context) => Container( - height: 20, - width: 20, - alignment: Alignment.center, - padding: const EdgeInsets.all(2), - decoration: BoxDecoration( - shape: BoxShape.circle, - border: _getBorder(), - ), - child: isChecked - ? Container( - height: 10, - width: 10, - decoration: const BoxDecoration( - shape: BoxShape.circle, - color: BrandColors.primary, - ), - ) - : null, - ); - - BoxBorder? _getBorder() => Border.all( - color: isChecked ? BrandColors.primary : BrandColors.gray1, - width: 2, - ); -} diff --git a/lib/ui/components/brand_text/brand_text.dart b/lib/ui/components/brand_text/brand_text.dart deleted file mode 100644 index 15307577..00000000 --- a/lib/ui/components/brand_text/brand_text.dart +++ /dev/null @@ -1,238 +0,0 @@ -import 'package:flutter/material.dart'; -import 'package:selfprivacy/config/text_themes.dart'; -export 'package:selfprivacy/utils/extensions/text_extensions.dart'; - -// TODO: Delete this file - -enum TextType { - h1, // right now only at onboarding and opened providers - h2, // cards titles - h3, // titles in about page - h4, // caption - h5, // Table data - body1, // normal - body2, // with opacity - medium, - small, - onboardingTitle, - buttonTitleText, // risen button title text, - h4Underlined, -} - -class BrandText extends StatelessWidget { - factory BrandText.h4( - final String? text, { - final TextStyle? style, - final TextAlign? textAlign, - }) => - BrandText( - text, - type: TextType.h4, - style: style, - softWrap: true, - overflow: TextOverflow.ellipsis, - maxLines: 2, - textAlign: textAlign, - ); - - factory BrandText.onboardingTitle( - final String text, { - final TextStyle? style, - }) => - BrandText( - text, - type: TextType.onboardingTitle, - style: style, - ); - factory BrandText.h3( - final String text, { - final TextStyle? style, - final TextAlign? textAlign, - }) => - BrandText( - text, - type: TextType.h3, - style: style, - textAlign: textAlign, - overflow: TextOverflow.ellipsis, - ); - - factory BrandText.h4Underlined( - final String? text, { - final TextStyle? style, - final TextAlign? textAlign, - }) => - BrandText( - text, - type: TextType.h4Underlined, - style: style, - softWrap: true, - overflow: TextOverflow.ellipsis, - maxLines: 2, - textAlign: textAlign, - ); - - factory BrandText.h1( - final String? text, { - final TextStyle? style, - final TextOverflow? overflow, - final bool? softWrap, - }) => - BrandText( - text, - type: TextType.h1, - style: style, - ); - factory BrandText.h2( - final String? text, { - final TextStyle? style, - final TextAlign? textAlign, - }) => - BrandText( - text, - type: TextType.h2, - style: style, - textAlign: textAlign, - ); - factory BrandText.body1(final String? text, {final TextStyle? style}) => - BrandText( - text, - type: TextType.body1, - style: style, - ); - factory BrandText.small(final String text, {final TextStyle? style}) => - BrandText( - text, - type: TextType.small, - style: style, - ); - factory BrandText.body2(final String? text, {final TextStyle? style}) => - BrandText( - text, - type: TextType.body2, - style: style, - ); - factory BrandText.buttonTitleText( - final String? text, { - final TextStyle? style, - }) => - BrandText( - text, - type: TextType.buttonTitleText, - style: style, - ); - - factory BrandText.h5( - final String? text, { - final TextStyle? style, - final TextAlign? textAlign, - }) => - BrandText( - text, - type: TextType.h5, - style: style, - textAlign: textAlign, - ); - factory BrandText.medium( - final String? text, { - final TextStyle? style, - final TextAlign? textAlign, - }) => - BrandText( - text, - type: TextType.medium, - style: style, - textAlign: textAlign, - ); - const BrandText( - this.text, { - required this.type, - super.key, - this.style, - this.overflow, - this.softWrap, - this.textAlign, - this.maxLines, - }); - - final String? text; - final TextStyle? style; - final TextType type; - final TextOverflow? overflow; - final bool? softWrap; - final TextAlign? textAlign; - final int? maxLines; - @override - Text build(final BuildContext context) { - TextStyle style; - final bool isDark = Theme.of(context).brightness == Brightness.dark; - switch (type) { - case TextType.h1: - style = isDark - ? headline1Style.copyWith(color: Colors.white) - : headline1Style; - break; - case TextType.h2: - style = isDark - ? headline2Style.copyWith(color: Colors.white) - : headline2Style; - break; - case TextType.h3: - style = isDark - ? headline3Style.copyWith(color: Colors.white) - : headline3Style; - break; - case TextType.h4: - style = isDark - ? headline4Style.copyWith(color: Colors.white) - : headline4Style; - break; - case TextType.h4Underlined: - style = isDark - ? headline4UnderlinedStyle.copyWith(color: Colors.white) - : headline4UnderlinedStyle; - break; - case TextType.h5: - style = isDark - ? headline5Style.copyWith(color: Colors.white) - : headline5Style; - break; - case TextType.body1: - style = isDark ? body1Style.copyWith(color: Colors.white) : body1Style; - break; - case TextType.body2: - style = isDark - ? body2Style.copyWith(color: Colors.white.withOpacity(0.6)) - : body2Style; - break; - case TextType.small: - style = isDark ? smallStyle.copyWith(color: Colors.white) : smallStyle; - break; - case TextType.onboardingTitle: - style = isDark - ? onboardingTitle.copyWith(color: Colors.white) - : onboardingTitle; - break; - case TextType.medium: - style = - isDark ? mediumStyle.copyWith(color: Colors.white) : mediumStyle; - break; - case TextType.buttonTitleText: - style = !isDark - ? buttonTitleText.copyWith(color: Colors.white) - : buttonTitleText; - break; - } - if (this.style != null) { - style = style.merge(this.style); - } - return Text( - text!, - style: style, - maxLines: maxLines, - overflow: overflow, - softWrap: softWrap, - textAlign: textAlign, - ); - } -} diff --git a/lib/ui/components/brand_timer/brand_timer.dart b/lib/ui/components/brand_timer/brand_timer.dart index 3ccf9a63..4d744cfc 100644 --- a/lib/ui/components/brand_timer/brand_timer.dart +++ b/lib/ui/components/brand_timer/brand_timer.dart @@ -2,7 +2,6 @@ import 'dart:async'; import 'package:easy_localization/easy_localization.dart'; import 'package:flutter/material.dart'; -import 'package:selfprivacy/ui/components/brand_text/brand_text.dart'; import 'package:selfprivacy/utils/named_font_weight.dart'; class BrandTimer extends StatefulWidget { @@ -52,11 +51,12 @@ class _BrandTimerState extends State { } @override - Widget build(final BuildContext context) => BrandText.medium( - _timeString, - style: const TextStyle( - fontWeight: NamedFontWeight.demiBold, - ), + Widget build(final BuildContext context) => Text( + _timeString ?? '', + style: Theme.of(context).textTheme.bodyMedium?.copyWith( + fontWeight: NamedFontWeight.demiBold, + color: Theme.of(context).colorScheme.onSurface, + ), ); void _getTime() { diff --git a/lib/ui/components/brand_button/brand_button.dart b/lib/ui/components/buttons/brand_button.dart similarity index 54% rename from lib/ui/components/brand_button/brand_button.dart rename to lib/ui/components/buttons/brand_button.dart index 28edd6b8..12c7c132 100644 --- a/lib/ui/components/brand_button/brand_button.dart +++ b/lib/ui/components/buttons/brand_button.dart @@ -1,7 +1,4 @@ import 'package:flutter/material.dart'; -import 'package:selfprivacy/ui/components/brand_text/brand_text.dart'; - -enum BrandButtonTypes { rised, text, iconText } class BrandButton { static ConstrainedBox rised({ @@ -58,53 +55,4 @@ class BrandButton { ), child: TextButton(onPressed: onPressed, child: Text(title)), ); - - static IconTextButton emptyWithIconText({ - required final VoidCallback onPressed, - required final String title, - required final Icon icon, - final Key? key, - }) => - IconTextButton( - key: key, - title: title, - onPressed: onPressed, - icon: icon, - ); -} - -class IconTextButton extends StatelessWidget { - const IconTextButton({ - super.key, - this.onPressed, - this.title, - this.icon, - }); - - final VoidCallback? onPressed; - final String? title; - final Icon? icon; - - @override - Widget build(final BuildContext context) => Material( - color: Colors.transparent, - child: InkWell( - onTap: onPressed, - child: Container( - height: 48, - width: double.infinity, - alignment: Alignment.center, - child: Row( - mainAxisAlignment: MainAxisAlignment.spaceBetween, - children: [ - BrandText.body1(title), - Padding( - padding: const EdgeInsets.all(12.0), - child: icon, - ) - ], - ), - ), - ), - ); } diff --git a/lib/ui/components/action_button/action_button.dart b/lib/ui/components/buttons/dialog_action_button.dart similarity index 81% rename from lib/ui/components/action_button/action_button.dart rename to lib/ui/components/buttons/dialog_action_button.dart index 4073393f..260cd493 100644 --- a/lib/ui/components/action_button/action_button.dart +++ b/lib/ui/components/buttons/dialog_action_button.dart @@ -1,7 +1,8 @@ import 'package:flutter/material.dart'; -class ActionButton extends StatelessWidget { - const ActionButton({ +/// Basically a [TextButton] to be used in dialogs +class DialogActionButton extends StatelessWidget { + const DialogActionButton({ super.key, this.text, this.onPressed, diff --git a/lib/ui/components/brand_button/outlined_button.dart b/lib/ui/components/buttons/outlined_button.dart similarity index 100% rename from lib/ui/components/brand_button/outlined_button.dart rename to lib/ui/components/buttons/outlined_button.dart diff --git a/lib/ui/components/brand_button/segmented_buttons.dart b/lib/ui/components/buttons/segmented_buttons.dart similarity index 70% rename from lib/ui/components/brand_button/segmented_buttons.dart rename to lib/ui/components/buttons/segmented_buttons.dart index 6dcf611b..b876f71d 100644 --- a/lib/ui/components/brand_button/segmented_buttons.dart +++ b/lib/ui/components/buttons/segmented_buttons.dart @@ -1,6 +1,16 @@ import 'package:flutter/material.dart'; +/// For some reason original [SegmentedButton] does not have animations. +/// +/// The [SegmentedButtons] was written for SelfPrivacy before [SegmentedButton] was introduced. +/// While it doesn't have that much options to pass, it has cute little animation. +/// It is based on [ToggleButtons]. class SegmentedButtons extends StatelessWidget { + /// Creates a segmented buttons widget. This is a SelfPrivacy implementation. + /// + /// Provide the button titles in [titles] as a [List]. + /// Current selection is provided in [isSelected] as a [List]. + /// This widget will call [onPressed] with the index of the button that was pressed. const SegmentedButtons({ required this.isSelected, required this.onPressed, @@ -8,15 +18,24 @@ class SegmentedButtons extends StatelessWidget { super.key, }); + /// The current selection state of the buttons. + /// + /// The length of this list must be equal to the length of [titles]. + /// Several buttons can be selected at the same time. final List isSelected; + + /// The callback that is called when a button is pressed. + /// It will be called with the index of the button that was pressed. final Function(int)? onPressed; + + /// The titles of the buttons. final List titles; @override Widget build(final BuildContext context) => LayoutBuilder( builder: (final context, final constraints) => ToggleButtons( constraints: BoxConstraints( - minWidth: (constraints.maxWidth - 8) / 3, + minWidth: (constraints.maxWidth - 8) / titles.length, minHeight: 40 + Theme.of(context).visualDensity.vertical * 4, ), borderRadius: BorderRadius.circular(48), diff --git a/lib/ui/components/jobs_content/jobs_content.dart b/lib/ui/components/jobs_content/jobs_content.dart index bafe94a7..32cd845c 100644 --- a/lib/ui/components/jobs_content/jobs_content.dart +++ b/lib/ui/components/jobs_content/jobs_content.dart @@ -6,10 +6,9 @@ import 'package:selfprivacy/logic/cubit/client_jobs/client_jobs_cubit.dart'; import 'package:selfprivacy/logic/cubit/server_installation/server_installation_cubit.dart'; import 'package:selfprivacy/logic/cubit/server_jobs/server_jobs_cubit.dart'; import 'package:selfprivacy/logic/models/json/server_job.dart'; -import 'package:selfprivacy/ui/components/brand_button/brand_button.dart'; +import 'package:selfprivacy/ui/components/buttons/brand_button.dart'; import 'package:selfprivacy/ui/components/brand_cards/brand_cards.dart'; import 'package:selfprivacy/ui/components/brand_loader/brand_loader.dart'; -import 'package:selfprivacy/ui/components/brand_text/brand_text.dart'; import 'package:selfprivacy/ui/components/jobs_content/server_job_card.dart'; import 'package:selfprivacy/ui/helpers/modals.dart'; @@ -32,7 +31,12 @@ class JobsContent extends StatelessWidget { if (state is JobsStateEmpty) { widgets = [ const SizedBox(height: 80), - Center(child: BrandText.body1('jobs.empty'.tr())), + Center( + child: Text( + 'jobs.empty'.tr(), + style: Theme.of(context).textTheme.bodyLarge, + ), + ), ]; if (installationState is ServerInstallationFinished) { @@ -109,8 +113,9 @@ class JobsContent extends StatelessWidget { children: [ const SizedBox(height: 15), Center( - child: BrandText.h2( + child: Text( 'jobs.title'.tr(), + style: Theme.of(context).textTheme.headlineSmall, ), ), const SizedBox(height: 20), diff --git a/lib/ui/components/progress_bar/progress_bar.dart b/lib/ui/components/progress_bar/progress_bar.dart index 00f1388e..5264adb7 100644 --- a/lib/ui/components/progress_bar/progress_bar.dart +++ b/lib/ui/components/progress_bar/progress_bar.dart @@ -1,6 +1,5 @@ import 'package:flutter/material.dart'; import 'package:selfprivacy/config/brand_colors.dart'; -import 'package:selfprivacy/config/text_themes.dart'; import 'package:selfprivacy/logic/cubit/app_settings/app_settings_cubit.dart'; class ProgressBar extends StatefulWidget { @@ -65,7 +64,7 @@ class _ProgressBarState extends State { Container( alignment: Alignment.centerLeft, decoration: BoxDecoration( - color: BrandColors.gray4, + color: const Color(0xFFDDDDDD), borderRadius: BorderRadius.circular(5), ), child: LayoutBuilder( @@ -119,3 +118,13 @@ class _ProgressBarState extends State { ); } } + +const TextStyle progressTextStyleLight = TextStyle( + fontSize: 11, + color: Colors.black, + height: 1.7, +); + +final TextStyle progressTextStyleDark = progressTextStyleLight.copyWith( + color: Colors.white, +); diff --git a/lib/ui/components/switch_block/switch_bloc.dart b/lib/ui/components/switch_block/switch_bloc.dart deleted file mode 100644 index 85ac2c68..00000000 --- a/lib/ui/components/switch_block/switch_bloc.dart +++ /dev/null @@ -1,36 +0,0 @@ -import 'package:flutter/material.dart'; -import 'package:selfprivacy/config/brand_colors.dart'; - -// TODO: Delete this file. - -class SwitcherBlock extends StatelessWidget { - const SwitcherBlock({ - required this.child, - required this.isActive, - required this.onChange, - super.key, - }); - - final Widget child; - final bool isActive; - final ValueChanged onChange; - - @override - Widget build(final BuildContext context) => Container( - padding: const EdgeInsets.symmetric(vertical: 16), - child: Row( - crossAxisAlignment: CrossAxisAlignment.start, - mainAxisAlignment: MainAxisAlignment.spaceBetween, - children: [ - Flexible(child: child), - const SizedBox(width: 5), - Switch( - activeColor: BrandColors.green1, - activeTrackColor: BrandColors.green2, - onChanged: onChange, - value: isActive, - ), - ], - ), - ); -} diff --git a/lib/ui/helpers/modals.dart b/lib/ui/helpers/modals.dart index 1750c2aa..77ddf2cb 100644 --- a/lib/ui/helpers/modals.dart +++ b/lib/ui/helpers/modals.dart @@ -2,7 +2,7 @@ import 'package:easy_localization/easy_localization.dart'; import 'package:flutter/material.dart'; import 'package:modal_bottom_sheet/modal_bottom_sheet.dart'; import 'package:selfprivacy/config/get_it_config.dart'; -import 'package:selfprivacy/ui/components/action_button/action_button.dart'; +import 'package:selfprivacy/ui/components/buttons/dialog_action_button.dart'; import 'package:selfprivacy/ui/components/brand_alert/brand_alert.dart'; Future showBrandBottomSheet({ @@ -30,12 +30,12 @@ void showPopUpAlert({ title: alertTitle ?? 'basis.alert'.tr(), contentText: description, actions: [ - ActionButton( + DialogActionButton( text: actionButtonTitle, isRed: true, onPressed: actionButtonOnPressed, ), - ActionButton( + DialogActionButton( text: cancelButtonTitle ?? 'basis.cancel'.tr(), onPressed: cancelButtonOnPressed, ), diff --git a/lib/ui/pages/backup_details/backup_details.dart b/lib/ui/pages/backup_details/backup_details.dart index 26e2dacc..36d76c29 100644 --- a/lib/ui/pages/backup_details/backup_details.dart +++ b/lib/ui/pages/backup_details/backup_details.dart @@ -5,11 +5,10 @@ import 'package:selfprivacy/logic/cubit/server_installation/server_installation_ import 'package:selfprivacy/logic/cubit/backups/backups_cubit.dart'; import 'package:selfprivacy/logic/models/json/backup.dart'; import 'package:selfprivacy/logic/models/state_types.dart'; -import 'package:selfprivacy/ui/components/brand_button/brand_button.dart'; +import 'package:selfprivacy/ui/components/buttons/brand_button.dart'; import 'package:selfprivacy/ui/components/brand_cards/outlined_card.dart'; import 'package:selfprivacy/ui/layouts/brand_hero_screen.dart'; import 'package:selfprivacy/ui/components/brand_icons/brand_icons.dart'; -import 'package:selfprivacy/ui/components/brand_text/brand_text.dart'; import 'package:selfprivacy/ui/helpers/modals.dart'; GlobalKey navigatorKey = GlobalKey(); @@ -59,7 +58,10 @@ class _BackupDetailsPageState extends State text: 'backup.initialize'.tr(), ), if (backupStatus == BackupStatusEnum.initializing) - BrandText.body1('backup.waiting_for_rebuild'.tr()), + Text( + 'backup.waiting_for_rebuild'.tr(), + style: Theme.of(context).textTheme.bodyMedium, + ), if (backupStatus != BackupStatusEnum.initializing && backupStatus != BackupStatusEnum.noKey) OutlinedCard( @@ -229,7 +231,10 @@ class _BackupDetailsPageState extends State ), ), if (backupStatus == BackupStatusEnum.error) - BrandText.body1(backupError.toString()), + Text( + backupError.toString(), + style: Theme.of(context).textTheme.bodyMedium, + ), ], ); } diff --git a/lib/ui/pages/devices/new_device.dart b/lib/ui/pages/devices/new_device.dart index 3d16101f..9a64fa72 100644 --- a/lib/ui/pages/devices/new_device.dart +++ b/lib/ui/pages/devices/new_device.dart @@ -3,7 +3,7 @@ import 'package:easy_localization/easy_localization.dart'; import 'package:flutter/material.dart'; import 'package:selfprivacy/logic/cubit/devices/devices_cubit.dart'; import 'package:selfprivacy/logic/cubit/server_installation/server_installation_cubit.dart'; -import 'package:selfprivacy/ui/components/brand_button/brand_button.dart'; +import 'package:selfprivacy/ui/components/buttons/brand_button.dart'; import 'package:selfprivacy/ui/layouts/brand_hero_screen.dart'; class NewDeviceScreen extends StatelessWidget { diff --git a/lib/ui/pages/more/about_application.dart b/lib/ui/pages/more/about_application.dart index 7feab555..54e493de 100644 --- a/lib/ui/pages/more/about_application.dart +++ b/lib/ui/pages/more/about_application.dart @@ -3,7 +3,6 @@ import 'package:flutter/material.dart'; import 'package:selfprivacy/logic/api_maps/graphql_maps/server_api/server_api.dart'; import 'package:selfprivacy/logic/cubit/server_installation/server_installation_cubit.dart'; import 'package:selfprivacy/ui/components/brand_md/brand_md.dart'; -import 'package:selfprivacy/ui/components/brand_text/brand_text.dart'; import 'package:package_info/package_info.dart'; import 'package:easy_localization/easy_localization.dart'; import 'package:selfprivacy/ui/layouts/brand_hero_screen.dart'; @@ -25,17 +24,19 @@ class AboutApplicationPage extends StatelessWidget { children: [ FutureBuilder( future: _packageVersion(), - builder: (final context, final snapshot) => BrandText.body1( + builder: (final context, final snapshot) => Text( 'about_application_page.application_version_text' .tr(args: [snapshot.data.toString()]), + style: Theme.of(context).textTheme.bodyLarge, ), ), if (isReady) FutureBuilder( future: _apiVersion(), - builder: (final context, final snapshot) => BrandText.body1( + builder: (final context, final snapshot) => Text( 'about_application_page.api_version_text' .tr(args: [snapshot.data.toString()]), + style: Theme.of(context).textTheme.bodyLarge, ), ), const SizedBox(height: 10), diff --git a/lib/ui/pages/more/app_settings/app_settings.dart b/lib/ui/pages/more/app_settings/app_settings.dart index be8cc40e..fc3ad75a 100644 --- a/lib/ui/pages/more/app_settings/app_settings.dart +++ b/lib/ui/pages/more/app_settings/app_settings.dart @@ -2,7 +2,7 @@ import 'package:auto_route/auto_route.dart'; import 'package:flutter/material.dart'; import 'package:selfprivacy/logic/cubit/app_settings/app_settings_cubit.dart'; import 'package:selfprivacy/logic/cubit/server_installation/server_installation_cubit.dart'; -import 'package:selfprivacy/ui/components/action_button/action_button.dart'; +import 'package:selfprivacy/ui/components/buttons/dialog_action_button.dart'; import 'package:selfprivacy/ui/components/brand_alert/brand_alert.dart'; import 'package:selfprivacy/ui/layouts/brand_hero_screen.dart'; import 'package:easy_localization/easy_localization.dart'; @@ -84,7 +84,7 @@ class _AppSettingsPageState extends State { title: 'modals.are_you_sure'.tr(), contentText: 'modals.delete_server_volume'.tr(), actions: [ - ActionButton( + DialogActionButton( text: 'modals.yes'.tr(), isRed: true, onPressed: () async { @@ -104,7 +104,7 @@ class _AppSettingsPageState extends State { Navigator.of(context).pop(); }, ), - ActionButton( + DialogActionButton( text: 'basis.cancel'.tr(), ), ], @@ -129,7 +129,7 @@ class _ResetAppTile extends StatelessWidget { title: 'modals.are_you_sure'.tr(), contentText: 'modals.purge_all_keys'.tr(), actions: [ - ActionButton( + DialogActionButton( text: 'modals.purge_all_keys_confirm'.tr(), isRed: true, onPressed: () { @@ -137,7 +137,7 @@ class _ResetAppTile extends StatelessWidget { Navigator.of(context).pop(); }, ), - ActionButton( + DialogActionButton( text: 'basis.cancel'.tr(), ), ], diff --git a/lib/ui/pages/more/console.dart b/lib/ui/pages/more/console.dart index cd13ca62..aca76bd1 100644 --- a/lib/ui/pages/more/console.dart +++ b/lib/ui/pages/more/console.dart @@ -77,8 +77,11 @@ class _ConsolePageState extends State { '${message.timeString}${isError ? '(Error)' : ''}: \n', style: TextStyle( fontWeight: FontWeight.bold, - color: - isError ? BrandColors.red1 : null, + color: isError + ? Theme.of(context) + .colorScheme + .error + : null, ), ), TextSpan(text: message.text), diff --git a/lib/ui/pages/onboarding/onboarding.dart b/lib/ui/pages/onboarding/onboarding.dart index efa38da4..2e035d53 100644 --- a/lib/ui/pages/onboarding/onboarding.dart +++ b/lib/ui/pages/onboarding/onboarding.dart @@ -1,7 +1,7 @@ import 'package:auto_route/auto_route.dart'; import 'package:flutter/material.dart'; import 'package:selfprivacy/logic/cubit/app_settings/app_settings_cubit.dart'; -import 'package:selfprivacy/ui/components/brand_button/brand_button.dart'; +import 'package:selfprivacy/ui/components/buttons/brand_button.dart'; import 'package:selfprivacy/ui/router/router.dart'; import 'package:easy_localization/easy_localization.dart'; diff --git a/lib/ui/pages/recovery_key/recovery_key.dart b/lib/ui/pages/recovery_key/recovery_key.dart index a7742b6d..ae153f64 100644 --- a/lib/ui/pages/recovery_key/recovery_key.dart +++ b/lib/ui/pages/recovery_key/recovery_key.dart @@ -6,7 +6,7 @@ import 'package:selfprivacy/config/get_it_config.dart'; import 'package:selfprivacy/logic/common_enum/common_enum.dart'; import 'package:selfprivacy/logic/cubit/recovery_key/recovery_key_cubit.dart'; import 'package:selfprivacy/logic/cubit/server_installation/server_installation_cubit.dart'; -import 'package:selfprivacy/ui/components/brand_button/brand_button.dart'; +import 'package:selfprivacy/ui/components/buttons/brand_button.dart'; import 'package:selfprivacy/ui/components/brand_cards/filled_card.dart'; import 'package:selfprivacy/ui/layouts/brand_hero_screen.dart'; import 'package:selfprivacy/ui/pages/recovery_key/recovery_key_receiving.dart'; diff --git a/lib/ui/pages/recovery_key/recovery_key_receiving.dart b/lib/ui/pages/recovery_key/recovery_key_receiving.dart index 85c4939f..10f2e7c0 100644 --- a/lib/ui/pages/recovery_key/recovery_key_receiving.dart +++ b/lib/ui/pages/recovery_key/recovery_key_receiving.dart @@ -1,6 +1,6 @@ import 'package:easy_localization/easy_localization.dart'; import 'package:flutter/material.dart'; -import 'package:selfprivacy/ui/components/brand_button/brand_button.dart'; +import 'package:selfprivacy/ui/components/buttons/brand_button.dart'; import 'package:selfprivacy/ui/layouts/brand_hero_screen.dart'; import 'package:selfprivacy/ui/components/info_box/info_box.dart'; diff --git a/lib/ui/pages/server_details/server_details_screen.dart b/lib/ui/pages/server_details/server_details_screen.dart index aa843b6c..6707d287 100644 --- a/lib/ui/pages/server_details/server_details_screen.dart +++ b/lib/ui/pages/server_details/server_details_screen.dart @@ -2,7 +2,6 @@ import 'package:auto_route/auto_route.dart'; import 'package:cubit_form/cubit_form.dart'; import 'package:easy_localization/easy_localization.dart'; import 'package:flutter/material.dart'; -import 'package:selfprivacy/config/brand_colors.dart'; import 'package:selfprivacy/logic/common_enum/common_enum.dart'; import 'package:selfprivacy/logic/cubit/client_jobs/client_jobs_cubit.dart'; import 'package:selfprivacy/logic/cubit/metrics/metrics_cubit.dart'; @@ -11,18 +10,17 @@ import 'package:selfprivacy/logic/cubit/server_installation/server_installation_ import 'package:selfprivacy/logic/cubit/server_volumes/server_volume_cubit.dart'; import 'package:selfprivacy/logic/models/auto_upgrade_settings.dart'; import 'package:selfprivacy/logic/models/job.dart'; -import 'package:selfprivacy/ui/components/brand_button/segmented_buttons.dart'; +import 'package:selfprivacy/ui/components/buttons/segmented_buttons.dart'; import 'package:selfprivacy/ui/components/brand_cards/filled_card.dart'; import 'package:selfprivacy/ui/layouts/brand_hero_screen.dart'; import 'package:selfprivacy/ui/components/brand_icons/brand_icons.dart'; import 'package:selfprivacy/ui/components/brand_loader/brand_loader.dart'; -import 'package:selfprivacy/ui/components/brand_text/brand_text.dart'; import 'package:selfprivacy/ui/components/list_tiles/list_tile_on_surface_variant.dart'; import 'package:selfprivacy/ui/pages/server_details/charts/cpu_chart.dart'; import 'package:selfprivacy/ui/pages/server_details/charts/network_charts.dart'; import 'package:selfprivacy/ui/pages/server_storage/storage_card.dart'; +import 'package:selfprivacy/utils/breakpoints.dart'; import 'package:selfprivacy/utils/extensions/duration.dart'; -import 'package:selfprivacy/utils/named_font_weight.dart'; import 'package:selfprivacy/utils/route_transitions/basic.dart'; import 'package:timezone/timezone.dart'; diff --git a/lib/ui/pages/server_details/text_details.dart b/lib/ui/pages/server_details/text_details.dart index 5f447901..03126ba5 100644 --- a/lib/ui/pages/server_details/text_details.dart +++ b/lib/ui/pages/server_details/text_details.dart @@ -23,15 +23,13 @@ class _TextDetails extends StatelessWidget { ), ), ), - ...details.metadata - .map( - (final metadata) => ListTileOnSurfaceVariant( - leadingIcon: metadata.type.icon, - title: metadata.name, - subtitle: metadata.value, - ), - ) - .toList(), + ...details.metadata.map( + (final metadata) => ListTileOnSurfaceVariant( + leadingIcon: metadata.type.icon, + title: metadata.name, + subtitle: metadata.value, + ), + ), ], ), ); @@ -39,24 +37,6 @@ class _TextDetails extends StatelessWidget { throw Exception('wrong state'); } } - - Widget getRowTitle(final String title) => Padding( - padding: const EdgeInsets.only(right: 10), - child: BrandText.h5( - title, - textAlign: TextAlign.right, - ), - ); - - Widget getRowValue(final String title, {final bool isBold = false}) => - BrandText.body1( - title, - style: isBold - ? const TextStyle( - fontWeight: NamedFontWeight.demiBold, - ) - : null, - ); } class _TempMessage extends StatelessWidget { @@ -69,7 +49,10 @@ class _TempMessage extends StatelessWidget { Widget build(final BuildContext context) => SizedBox( height: MediaQuery.of(context).size.height - 100, child: Center( - child: BrandText.body2(message), + child: Text( + message, + style: Theme.of(context).textTheme.bodyMedium, + ), ), ); } diff --git a/lib/ui/pages/server_details/time_zone/time_zone.dart b/lib/ui/pages/server_details/time_zone/time_zone.dart index a93b8f23..6863bfe8 100644 --- a/lib/ui/pages/server_details/time_zone/time_zone.dart +++ b/lib/ui/pages/server_details/time_zone/time_zone.dart @@ -57,66 +57,72 @@ class _SelectTimezoneState extends State { } @override - Widget build(final BuildContext context) => Scaffold( - appBar: AppBar( - title: isSearching - ? TextField( - readOnly: false, - textAlign: TextAlign.start, - textInputAction: TextInputAction.next, - enabled: true, - controller: searchController, - decoration: InputDecoration( - errorText: null, - hintText: 'server.timezone_search_bar'.tr(), - ), - ) - : Padding( - padding: const EdgeInsets.only(top: 4.0), - child: Text('server.select_timezone'.tr()), + Widget build(final BuildContext context) { + final isDesktop = Breakpoints.mediumAndUp.isActive(context); + return Scaffold( + appBar: AppBar( + automaticallyImplyLeading: false, + title: (isDesktop || isSearching) + ? TextField( + readOnly: false, + textAlign: TextAlign.start, + textInputAction: TextInputAction.next, + enabled: true, + controller: searchController, + decoration: InputDecoration( + errorText: null, + hintText: 'server.timezone_search_bar'.tr(), ), - leading: IconButton( - icon: const Icon(Icons.arrow_back), - onPressed: isSearching - ? () => setState(() => isSearching = false) - : () => Navigator.of(context).pop(), - ), - actions: [ - if (!isSearching) - IconButton( - icon: const Icon(Icons.search), - onPressed: () => setState(() => isSearching = true), + ) + : Padding( + padding: const EdgeInsets.only(top: 4.0), + child: Text('server.select_timezone'.tr()), ), - ], + leading: !isDesktop + ? IconButton( + icon: const Icon(Icons.arrow_back), + onPressed: isSearching + ? () => setState(() => isSearching = false) + : () => Navigator.of(context).pop(), + ) + : null, + actions: [ + if (!isSearching && !isDesktop) + IconButton( + icon: const Icon(Icons.search), + onPressed: () => setState(() => isSearching = true), + ), + ], + ), + body: SafeArea( + child: ListView( + controller: scrollController, + children: locations + .where( + (final Location location) => timezoneFilterValue == null + ? true + : location.name + .toLowerCase() + .contains(timezoneFilterValue!) || + Duration( + milliseconds: location.currentTimeZone.offset, + ) + .toDayHourMinuteFormat() + .contains(timezoneFilterValue!), + ) + .toList() + .asMap() + .map( + (final key, final value) => locationToListTile(key, value), + ) + .values + .toList(), ), - body: SafeArea( - child: ListView( - controller: scrollController, - children: locations - .where( - (final Location location) => timezoneFilterValue == null - ? true - : location.name - .toLowerCase() - .contains(timezoneFilterValue!) || - Duration( - milliseconds: location.currentTimeZone.offset, - ) - .toDayHourMinuteFormat() - .contains(timezoneFilterValue!), - ) - .toList() - .asMap() - .map( - (final key, final value) => locationToListTile(key, value), - ) - .values - .toList(), - ), - ), - ); + ), + ); + } - MapEntry locationToListTile( + MapEntry locationToListTile( final int key, final Location location, ) { @@ -126,46 +132,19 @@ class _SelectTimezoneState extends State { return MapEntry( key, - Container( - height: 75, - padding: const EdgeInsets.symmetric(horizontal: 20), - decoration: const BoxDecoration( - border: Border( - bottom: BorderSide( - color: BrandColors.dividerColor, - ), - ), + ListTile( + title: Text( + location.name, ), - child: InkWell( - onTap: () { - context.read().repository.setTimezone( - location.name, - ); - Navigator.of(context).pop(); - }, - child: Container( - padding: const EdgeInsets.symmetric(vertical: 16), - child: Column( - crossAxisAlignment: CrossAxisAlignment.start, - mainAxisAlignment: MainAxisAlignment.center, - children: [ - BrandText.body1( - location.name, - style: const TextStyle( - fontSize: 16, - fontWeight: FontWeight.bold, - ), - ), - BrandText.small( - 'GMT ${duration.toDayHourMinuteFormat()} ${area.isNotEmpty ? '($area)' : ''}', - style: const TextStyle( - fontSize: 13, - ), - ), - ], - ), - ), + subtitle: Text( + 'GMT ${duration.toDayHourMinuteFormat()} ${area.isNotEmpty ? '($area)' : ''}', ), + onTap: () { + context.read().repository.setTimezone( + location.name, + ); + Navigator.of(context).pop(); + }, ), ); } diff --git a/lib/ui/pages/server_storage/binds_migration/migration_process_page.dart b/lib/ui/pages/server_storage/binds_migration/migration_process_page.dart index 227fb501..8d42cb6f 100644 --- a/lib/ui/pages/server_storage/binds_migration/migration_process_page.dart +++ b/lib/ui/pages/server_storage/binds_migration/migration_process_page.dart @@ -2,7 +2,7 @@ import 'package:easy_localization/easy_localization.dart'; import 'package:flutter/material.dart'; import 'package:selfprivacy/logic/cubit/server_jobs/server_jobs_cubit.dart'; import 'package:selfprivacy/logic/models/json/server_job.dart'; -import 'package:selfprivacy/ui/components/brand_button/brand_button.dart'; +import 'package:selfprivacy/ui/components/buttons/brand_button.dart'; import 'package:selfprivacy/ui/layouts/brand_hero_screen.dart'; import 'package:selfprivacy/ui/components/brand_linear_indicator/brand_linear_indicator.dart'; import 'package:selfprivacy/ui/pages/root_route.dart'; diff --git a/lib/ui/pages/server_storage/binds_migration/services_migration.dart b/lib/ui/pages/server_storage/binds_migration/services_migration.dart index 71859116..5c3e4eb6 100644 --- a/lib/ui/pages/server_storage/binds_migration/services_migration.dart +++ b/lib/ui/pages/server_storage/binds_migration/services_migration.dart @@ -6,7 +6,7 @@ import 'package:selfprivacy/logic/cubit/services/services_cubit.dart'; import 'package:selfprivacy/logic/models/disk_size.dart'; import 'package:selfprivacy/logic/models/service.dart'; import 'package:selfprivacy/ui/components/brand_bottom_sheet/brand_bottom_sheet.dart'; -import 'package:selfprivacy/ui/components/brand_button/brand_button.dart'; +import 'package:selfprivacy/ui/components/buttons/brand_button.dart'; import 'package:selfprivacy/ui/components/brand_header/brand_header.dart'; import 'package:selfprivacy/ui/components/info_box/info_box.dart'; import 'package:selfprivacy/logic/models/disk_status.dart'; diff --git a/lib/ui/pages/server_storage/extending_volume.dart b/lib/ui/pages/server_storage/extending_volume.dart index 50cb93be..41c81140 100644 --- a/lib/ui/pages/server_storage/extending_volume.dart +++ b/lib/ui/pages/server_storage/extending_volume.dart @@ -6,7 +6,7 @@ import 'package:selfprivacy/logic/cubit/provider_volumes/provider_volume_cubit.d import 'package:selfprivacy/logic/cubit/server_volumes/server_volume_cubit.dart'; import 'package:selfprivacy/logic/models/disk_size.dart'; import 'package:selfprivacy/logic/models/price.dart'; -import 'package:selfprivacy/ui/components/brand_button/brand_button.dart'; +import 'package:selfprivacy/ui/components/buttons/brand_button.dart'; import 'package:selfprivacy/ui/layouts/brand_hero_screen.dart'; import 'package:selfprivacy/logic/models/disk_status.dart'; diff --git a/lib/ui/pages/server_storage/server_storage.dart b/lib/ui/pages/server_storage/server_storage.dart index 7b23e275..81e0fc07 100644 --- a/lib/ui/pages/server_storage/server_storage.dart +++ b/lib/ui/pages/server_storage/server_storage.dart @@ -5,7 +5,7 @@ import 'package:flutter_svg/svg.dart'; import 'package:selfprivacy/logic/cubit/server_installation/server_installation_cubit.dart'; import 'package:selfprivacy/logic/cubit/services/services_cubit.dart'; import 'package:selfprivacy/logic/models/service.dart'; -import 'package:selfprivacy/ui/components/brand_button/outlined_button.dart'; +import 'package:selfprivacy/ui/components/buttons/outlined_button.dart'; import 'package:selfprivacy/ui/layouts/brand_hero_screen.dart'; import 'package:selfprivacy/logic/models/disk_status.dart'; import 'package:selfprivacy/ui/components/storage_list_items/server_storage_list_item.dart'; diff --git a/lib/ui/pages/services/services.dart b/lib/ui/pages/services/services.dart index 80e03101..e5320a35 100644 --- a/lib/ui/pages/services/services.dart +++ b/lib/ui/pages/services/services.dart @@ -1,3 +1,5 @@ +import 'dart:async'; + import 'package:auto_route/auto_route.dart'; import 'package:flutter/material.dart'; import 'package:flutter_svg/flutter_svg.dart'; @@ -7,7 +9,6 @@ import 'package:selfprivacy/logic/cubit/services/services_cubit.dart'; import 'package:selfprivacy/logic/models/service.dart'; import 'package:selfprivacy/logic/models/state_types.dart'; import 'package:selfprivacy/ui/components/brand_header/brand_header.dart'; -import 'package:selfprivacy/ui/components/brand_text/brand_text.dart'; import 'package:selfprivacy/ui/components/icon_status_mask/icon_status_mask.dart'; import 'package:selfprivacy/ui/components/not_ready_card/not_ready_card.dart'; import 'package:easy_localization/easy_localization.dart'; @@ -45,24 +46,25 @@ class _ServicesPageState extends State { : null, body: RefreshIndicator( onRefresh: () async { - context.read().reload(); + unawaited(context.read().reload()); }, child: ListView( padding: paddingH15V0, children: [ - BrandText.body1('basis.services_title'.tr()), + Text( + 'basis.services_title'.tr(), + style: Theme.of(context).textTheme.bodyLarge, + ), const SizedBox(height: 24), if (!isReady) ...[const NotReadyCard(), const SizedBox(height: 24)], - ...services - .map( - (final service) => Padding( - padding: const EdgeInsets.only( - bottom: 30, - ), - child: _Card(service: service), - ), - ) - .toList() + ...services.map( + (final service) => Padding( + padding: const EdgeInsets.only( + bottom: 30, + ), + child: _Card(service: service), + ), + ) ], ), ), @@ -106,8 +108,10 @@ class _Card extends StatelessWidget { child: InkResponse( highlightShape: BoxShape.rectangle, onTap: isReady - ? () => context.pushRoute( - ServiceRoute(serviceId: service.id), + ? () => unawaited( + context.pushRoute( + ServiceRoute(serviceId: service.id), + ), ) : null, child: Padding( @@ -134,23 +138,17 @@ class _Card extends StatelessWidget { Column( crossAxisAlignment: CrossAxisAlignment.start, children: [ - const SizedBox(height: 10), - BrandText.h2(service.displayName), - const SizedBox(height: 10), + const SizedBox(height: 12), + Text( + service.displayName, + style: Theme.of(context).textTheme.headlineMedium, + ), + const SizedBox(height: 8), if (service.url != '' && service.url != null) Column( children: [ - GestureDetector( - onTap: () => launchURL( - service.url, - ), - child: Text( - '${service.url}', - style: TextStyle( - color: Theme.of(context).colorScheme.secondary, - decoration: TextDecoration.underline, - ), - ), + _ServiceLink( + url: service.url ?? '', ), const SizedBox(height: 10), ], @@ -158,19 +156,22 @@ class _Card extends StatelessWidget { if (service.id == 'mailserver') Column( children: [ - Text( - domainName, - style: TextStyle( - color: Theme.of(context).colorScheme.primary, - decoration: TextDecoration.underline, - ), + _ServiceLink( + url: domainName, + isActive: false, ), const SizedBox(height: 10), ], ), - BrandText.body2(service.loginInfo), + Text( + service.loginInfo, + style: Theme.of(context).textTheme.bodyMedium, + ), const SizedBox(height: 10), - BrandText.body2(service.description), + Text( + service.description, + style: Theme.of(context).textTheme.bodyMedium, + ), const SizedBox(height: 10), ], ) @@ -181,3 +182,29 @@ class _Card extends StatelessWidget { ); } } + +class _ServiceLink extends StatelessWidget { + const _ServiceLink({ + required this.url, + this.isActive = true, + }); + + final String url; + final bool isActive; + + @override + Widget build(final BuildContext context) => GestureDetector( + onTap: isActive + ? () => launchURL( + url, + ) + : null, + child: Text( + url, + style: Theme.of(context).textTheme.bodyMedium?.copyWith( + color: Theme.of(context).colorScheme.primary, + decoration: TextDecoration.underline, + ), + ), + ); +} diff --git a/lib/ui/pages/setup/initializing/initializing.dart b/lib/ui/pages/setup/initializing/initializing.dart index e589e4f7..5b598af0 100644 --- a/lib/ui/pages/setup/initializing/initializing.dart +++ b/lib/ui/pages/setup/initializing/initializing.dart @@ -1,3 +1,5 @@ +import 'dart:async'; + import 'package:auto_route/auto_route.dart'; import 'package:cubit_form/cubit_form.dart'; import 'package:easy_localization/easy_localization.dart'; @@ -10,9 +12,8 @@ import 'package:selfprivacy/logic/cubit/forms/setup/initializing/dns_provider_fo import 'package:selfprivacy/logic/cubit/forms/setup/initializing/domain_setup_cubit.dart'; import 'package:selfprivacy/logic/cubit/forms/setup/initializing/root_user_form_cubit.dart'; import 'package:selfprivacy/logic/cubit/support_system/support_system_cubit.dart'; -import 'package:selfprivacy/ui/components/brand_button/brand_button.dart'; -import 'package:selfprivacy/ui/components/brand_button/outlined_button.dart'; -import 'package:selfprivacy/ui/components/brand_text/brand_text.dart'; +import 'package:selfprivacy/ui/components/buttons/brand_button.dart'; +import 'package:selfprivacy/ui/components/buttons/outlined_button.dart'; import 'package:selfprivacy/ui/components/brand_timer/brand_timer.dart'; import 'package:selfprivacy/ui/components/progress_bar/progress_bar.dart'; import 'package:selfprivacy/ui/components/support_drawer/support_drawer.dart'; @@ -395,7 +396,10 @@ class InitializingPage extends StatelessWidget { color: Colors.white, ), const SizedBox(width: 10), - BrandText.buttonTitleText('domain.update_list'.tr()), + Text( + 'domain.update_list'.tr(), + style: Theme.of(context).textTheme.bodyLarge, + ), ], ), ), @@ -403,8 +407,8 @@ class InitializingPage extends StatelessWidget { if (state is Loaded) ...[ const SizedBox(height: 32), BrandButton.filled( - onPressed: () => - context.read().saveDomain(), + onPressed: () => unawaited( + context.read().saveDomain()), text: 'initializing.save_domain'.tr(), ), ], diff --git a/lib/ui/pages/setup/initializing/server_provider_picker.dart b/lib/ui/pages/setup/initializing/server_provider_picker.dart index 6813d9cd..4e09ae82 100644 --- a/lib/ui/pages/setup/initializing/server_provider_picker.dart +++ b/lib/ui/pages/setup/initializing/server_provider_picker.dart @@ -6,8 +6,8 @@ import 'package:selfprivacy/logic/cubit/app_config_dependent/authentication_depe import 'package:selfprivacy/logic/cubit/forms/setup/initializing/provider_form_cubit.dart'; import 'package:selfprivacy/logic/cubit/support_system/support_system_cubit.dart'; import 'package:selfprivacy/logic/models/hive/server_details.dart'; -import 'package:selfprivacy/ui/components/brand_button/brand_button.dart'; -import 'package:selfprivacy/ui/components/brand_button/outlined_button.dart'; +import 'package:selfprivacy/ui/components/buttons/brand_button.dart'; +import 'package:selfprivacy/ui/components/buttons/outlined_button.dart'; import 'package:selfprivacy/ui/components/brand_cards/outlined_card.dart'; import 'package:selfprivacy/ui/components/info_box/info_box.dart'; import 'package:selfprivacy/ui/layouts/responsive_layout_with_infobox.dart'; diff --git a/lib/ui/pages/setup/initializing/server_type_picker.dart b/lib/ui/pages/setup/initializing/server_type_picker.dart index 2b9f1748..3c1c5380 100644 --- a/lib/ui/pages/setup/initializing/server_type_picker.dart +++ b/lib/ui/pages/setup/initializing/server_type_picker.dart @@ -5,7 +5,7 @@ import 'package:selfprivacy/logic/cubit/app_config_dependent/authentication_depe import 'package:selfprivacy/logic/cubit/app_settings/app_settings_cubit.dart'; import 'package:selfprivacy/logic/models/server_provider_location.dart'; import 'package:selfprivacy/logic/models/server_type.dart'; -import 'package:selfprivacy/ui/components/brand_button/brand_button.dart'; +import 'package:selfprivacy/ui/components/buttons/brand_button.dart'; import 'package:selfprivacy/ui/components/info_box/info_box.dart'; import 'package:selfprivacy/ui/layouts/responsive_layout_with_infobox.dart'; diff --git a/lib/ui/pages/setup/recovering/recover_by_new_device_key.dart b/lib/ui/pages/setup/recovering/recover_by_new_device_key.dart index 7eeb2812..ea264749 100644 --- a/lib/ui/pages/setup/recovering/recover_by_new_device_key.dart +++ b/lib/ui/pages/setup/recovering/recover_by_new_device_key.dart @@ -1,7 +1,7 @@ import 'package:easy_localization/easy_localization.dart'; import 'package:flutter/material.dart'; import 'package:selfprivacy/logic/cubit/forms/setup/recovering/recovery_device_form_cubit.dart'; -import 'package:selfprivacy/ui/components/brand_button/brand_button.dart'; +import 'package:selfprivacy/ui/components/buttons/brand_button.dart'; import 'package:selfprivacy/ui/layouts/brand_hero_screen.dart'; import 'package:selfprivacy/utils/route_transitions/basic.dart'; import 'package:cubit_form/cubit_form.dart'; diff --git a/lib/ui/pages/setup/recovering/recover_by_old_token.dart b/lib/ui/pages/setup/recovering/recover_by_old_token.dart index d9dbba3a..d08e6bf7 100644 --- a/lib/ui/pages/setup/recovering/recover_by_old_token.dart +++ b/lib/ui/pages/setup/recovering/recover_by_old_token.dart @@ -1,7 +1,7 @@ import 'package:easy_localization/easy_localization.dart'; import 'package:flutter/material.dart'; import 'package:selfprivacy/logic/cubit/forms/setup/recovering/recovery_device_form_cubit.dart'; -import 'package:selfprivacy/ui/components/brand_button/brand_button.dart'; +import 'package:selfprivacy/ui/components/buttons/brand_button.dart'; import 'package:selfprivacy/ui/layouts/brand_hero_screen.dart'; import 'package:selfprivacy/ui/components/brand_md/brand_md.dart'; import 'package:cubit_form/cubit_form.dart'; diff --git a/lib/ui/pages/setup/recovering/recover_by_recovery_key.dart b/lib/ui/pages/setup/recovering/recover_by_recovery_key.dart index bd308f31..859a6eca 100644 --- a/lib/ui/pages/setup/recovering/recover_by_recovery_key.dart +++ b/lib/ui/pages/setup/recovering/recover_by_recovery_key.dart @@ -4,7 +4,7 @@ import 'package:flutter/material.dart'; import 'package:selfprivacy/logic/cubit/forms/factories/field_cubit_factory.dart'; import 'package:selfprivacy/logic/cubit/forms/setup/recovering/recovery_device_form_cubit.dart'; import 'package:selfprivacy/logic/cubit/server_installation/server_installation_cubit.dart'; -import 'package:selfprivacy/ui/components/brand_button/brand_button.dart'; +import 'package:selfprivacy/ui/components/buttons/brand_button.dart'; import 'package:selfprivacy/ui/layouts/brand_hero_screen.dart'; class RecoverByRecoveryKey extends StatelessWidget { diff --git a/lib/ui/pages/setup/recovering/recovery_confirm_backblaze.dart b/lib/ui/pages/setup/recovering/recovery_confirm_backblaze.dart index 12c23d54..f758f5d2 100644 --- a/lib/ui/pages/setup/recovering/recovery_confirm_backblaze.dart +++ b/lib/ui/pages/setup/recovering/recovery_confirm_backblaze.dart @@ -5,7 +5,7 @@ import 'package:selfprivacy/config/brand_theme.dart'; import 'package:selfprivacy/logic/cubit/forms/setup/initializing/backblaze_form_cubit.dart'; import 'package:selfprivacy/logic/cubit/server_installation/server_installation_cubit.dart'; import 'package:selfprivacy/ui/components/brand_bottom_sheet/brand_bottom_sheet.dart'; -import 'package:selfprivacy/ui/components/brand_button/brand_button.dart'; +import 'package:selfprivacy/ui/components/buttons/brand_button.dart'; import 'package:selfprivacy/ui/layouts/brand_hero_screen.dart'; import 'package:selfprivacy/ui/components/brand_md/brand_md.dart'; diff --git a/lib/ui/pages/setup/recovering/recovery_confirm_cloudflare.dart b/lib/ui/pages/setup/recovering/recovery_confirm_cloudflare.dart index 4bf670a3..e8969173 100644 --- a/lib/ui/pages/setup/recovering/recovery_confirm_cloudflare.dart +++ b/lib/ui/pages/setup/recovering/recovery_confirm_cloudflare.dart @@ -5,7 +5,7 @@ import 'package:selfprivacy/config/brand_theme.dart'; import 'package:selfprivacy/logic/cubit/forms/setup/initializing/dns_provider_form_cubit.dart'; import 'package:selfprivacy/logic/cubit/server_installation/server_installation_cubit.dart'; import 'package:selfprivacy/ui/components/brand_bottom_sheet/brand_bottom_sheet.dart'; -import 'package:selfprivacy/ui/components/brand_button/brand_button.dart'; +import 'package:selfprivacy/ui/components/buttons/brand_button.dart'; import 'package:selfprivacy/ui/layouts/brand_hero_screen.dart'; import 'package:selfprivacy/ui/components/brand_md/brand_md.dart'; diff --git a/lib/ui/pages/setup/recovering/recovery_confirm_server.dart b/lib/ui/pages/setup/recovering/recovery_confirm_server.dart index 948e2288..9ad22ebc 100644 --- a/lib/ui/pages/setup/recovering/recovery_confirm_server.dart +++ b/lib/ui/pages/setup/recovering/recovery_confirm_server.dart @@ -2,7 +2,7 @@ import 'package:easy_localization/easy_localization.dart'; import 'package:flutter/material.dart'; import 'package:selfprivacy/logic/cubit/app_config_dependent/authentication_dependend_cubit.dart'; import 'package:selfprivacy/logic/models/server_basic_info.dart'; -import 'package:selfprivacy/ui/components/brand_button/brand_button.dart'; +import 'package:selfprivacy/ui/components/buttons/brand_button.dart'; import 'package:selfprivacy/ui/components/brand_cards/filled_card.dart'; import 'package:selfprivacy/ui/layouts/brand_hero_screen.dart'; diff --git a/lib/ui/pages/setup/recovering/recovery_method_select.dart b/lib/ui/pages/setup/recovering/recovery_method_select.dart index 8aaefe35..72f557d3 100644 --- a/lib/ui/pages/setup/recovering/recovery_method_select.dart +++ b/lib/ui/pages/setup/recovering/recovery_method_select.dart @@ -2,7 +2,7 @@ import 'package:easy_localization/easy_localization.dart'; import 'package:flutter/material.dart'; import 'package:flutter_bloc/flutter_bloc.dart'; import 'package:selfprivacy/logic/cubit/server_installation/server_installation_cubit.dart'; -import 'package:selfprivacy/ui/components/brand_button/brand_button.dart'; +import 'package:selfprivacy/ui/components/buttons/brand_button.dart'; import 'package:selfprivacy/ui/components/brand_cards/outlined_card.dart'; import 'package:selfprivacy/ui/layouts/brand_hero_screen.dart'; import 'package:selfprivacy/ui/pages/setup/recovering/recover_by_old_token.dart'; diff --git a/lib/ui/pages/setup/recovering/recovery_routing.dart b/lib/ui/pages/setup/recovering/recovery_routing.dart index 2fee7297..193e3292 100644 --- a/lib/ui/pages/setup/recovering/recovery_routing.dart +++ b/lib/ui/pages/setup/recovering/recovery_routing.dart @@ -5,7 +5,7 @@ import 'package:flutter/material.dart'; import 'package:selfprivacy/logic/cubit/server_installation/server_installation_cubit.dart'; import 'package:selfprivacy/logic/cubit/forms/factories/field_cubit_factory.dart'; import 'package:selfprivacy/logic/cubit/forms/setup/recovering/recovery_domain_form_cubit.dart'; -import 'package:selfprivacy/ui/components/brand_button/brand_button.dart'; +import 'package:selfprivacy/ui/components/buttons/brand_button.dart'; import 'package:selfprivacy/ui/layouts/brand_hero_screen.dart'; import 'package:selfprivacy/ui/pages/root_route.dart'; import 'package:selfprivacy/ui/pages/setup/recovering/recover_by_old_token.dart'; diff --git a/lib/ui/pages/setup/recovering/recovery_server_provider_connected.dart b/lib/ui/pages/setup/recovering/recovery_server_provider_connected.dart index 50c99ca7..a892efc1 100644 --- a/lib/ui/pages/setup/recovering/recovery_server_provider_connected.dart +++ b/lib/ui/pages/setup/recovering/recovery_server_provider_connected.dart @@ -3,7 +3,7 @@ import 'package:flutter/material.dart'; import 'package:selfprivacy/config/brand_theme.dart'; import 'package:selfprivacy/logic/cubit/forms/setup/initializing/provider_form_cubit.dart'; import 'package:selfprivacy/ui/components/brand_bottom_sheet/brand_bottom_sheet.dart'; -import 'package:selfprivacy/ui/components/brand_button/brand_button.dart'; +import 'package:selfprivacy/ui/components/buttons/brand_button.dart'; import 'package:selfprivacy/ui/layouts/brand_hero_screen.dart'; import 'package:cubit_form/cubit_form.dart'; import 'package:selfprivacy/logic/cubit/server_installation/server_installation_cubit.dart'; diff --git a/lib/ui/pages/users/empty.dart b/lib/ui/pages/users/empty.dart index dc2d292b..f58dc740 100644 --- a/lib/ui/pages/users/empty.dart +++ b/lib/ui/pages/users/empty.dart @@ -11,21 +11,25 @@ class _NoUsers extends StatelessWidget { child: Column( mainAxisAlignment: MainAxisAlignment.center, children: [ - const Icon(BrandIcons.users, size: 50, color: BrandColors.grey7), + Icon( + BrandIcons.users, + size: 50, + color: Theme.of(context).colorScheme.onBackground, + ), const SizedBox(height: 20), - BrandText.h2( + Text( 'users.nobody_here'.tr(), - style: const TextStyle( - color: BrandColors.grey7, - ), + style: Theme.of(context).textTheme.headlineMedium?.copyWith( + color: Theme.of(context).colorScheme.onBackground, + ), ), const SizedBox(height: 10), - BrandText.medium( + Text( text, textAlign: TextAlign.center, - style: const TextStyle( - color: BrandColors.grey7, - ), + style: Theme.of(context).textTheme.titleSmall?.copyWith( + color: Theme.of(context).colorScheme.onBackground, + ), ), ], ), @@ -43,21 +47,25 @@ class _CouldNotLoadUsers extends StatelessWidget { child: Column( mainAxisAlignment: MainAxisAlignment.center, children: [ - const Icon(BrandIcons.users, size: 50, color: BrandColors.grey7), + Icon( + BrandIcons.users, + size: 50, + color: Theme.of(context).colorScheme.onBackground, + ), const SizedBox(height: 20), - BrandText.h2( + Text( 'users.could_not_fetch_users'.tr(), - style: const TextStyle( - color: BrandColors.grey7, - ), + style: Theme.of(context).textTheme.headlineMedium?.copyWith( + color: Theme.of(context).colorScheme.onBackground, + ), ), const SizedBox(height: 10), - BrandText.medium( + Text( text, textAlign: TextAlign.center, - style: const TextStyle( - color: BrandColors.grey7, - ), + style: Theme.of(context).textTheme.titleSmall?.copyWith( + color: Theme.of(context).colorScheme.onBackground, + ), ), ], ), diff --git a/lib/ui/pages/users/user.dart b/lib/ui/pages/users/user.dart index 0ce6d8cc..bbc01012 100644 --- a/lib/ui/pages/users/user.dart +++ b/lib/ui/pages/users/user.dart @@ -28,17 +28,17 @@ class _User extends StatelessWidget { ), const SizedBox(width: 20), Flexible( - child: isRootUser - ? BrandText.h4Underlined(user.login) - // cross out text if user not found on server - : BrandText.h4( - user.login, - style: user.isFoundOnServer - ? null - : const TextStyle( - decoration: TextDecoration.lineThrough, - ), + child: Text( + user.login, + style: Theme.of(context).textTheme.titleMedium?.copyWith( + color: Theme.of(context).colorScheme.onBackground, + decoration: isRootUser + ? TextDecoration.underline + : user.isFoundOnServer + ? TextDecoration.none + : TextDecoration.lineThrough, ), + ), ), ], ), diff --git a/lib/ui/pages/users/users.dart b/lib/ui/pages/users/users.dart index 8b3c5dfd..2ae93648 100644 --- a/lib/ui/pages/users/users.dart +++ b/lib/ui/pages/users/users.dart @@ -13,13 +13,12 @@ import 'package:selfprivacy/logic/cubit/users/users_cubit.dart'; import 'package:selfprivacy/logic/models/job.dart'; import 'package:selfprivacy/logic/models/hive/user.dart'; import 'package:selfprivacy/ui/components/brand_bottom_sheet/brand_bottom_sheet.dart'; -import 'package:selfprivacy/ui/components/brand_button/brand_button.dart'; -import 'package:selfprivacy/ui/components/brand_button/outlined_button.dart'; +import 'package:selfprivacy/ui/components/buttons/brand_button.dart'; +import 'package:selfprivacy/ui/components/buttons/outlined_button.dart'; import 'package:selfprivacy/ui/components/brand_cards/filled_card.dart'; import 'package:selfprivacy/ui/components/brand_header/brand_header.dart'; import 'package:selfprivacy/ui/layouts/brand_hero_screen.dart'; import 'package:selfprivacy/ui/components/brand_icons/brand_icons.dart'; -import 'package:selfprivacy/ui/components/brand_text/brand_text.dart'; import 'package:selfprivacy/ui/components/info_box/info_box.dart'; import 'package:selfprivacy/ui/components/list_tiles/list_tile_on_surface_variant.dart'; import 'package:selfprivacy/ui/components/not_ready_card/not_ready_card.dart'; diff --git a/lib/utils/extensions/text_extensions.dart b/lib/utils/extensions/text_extensions.dart index bfacc600..a00f7096 100644 --- a/lib/utils/extensions/text_extensions.dart +++ b/lib/utils/extensions/text_extensions.dart @@ -1,4 +1,4 @@ -import 'package:flutter/cupertino.dart'; +import 'package:flutter/material.dart'; extension TextExtension on Text { Text withColor(final Color color) => Text(