From b9eae35fda323dd2c6fb3a1d85a5101f08016b3f Mon Sep 17 00:00:00 2001 From: problematicconsumer Date: Fri, 10 Nov 2023 15:35:44 +0330 Subject: [PATCH] Fix ui bugs --- lib/features/common/nested_app_bar.dart | 3 +- lib/features/common/profile_tile.dart | 30 +++-- lib/features/home/view/home_page.dart | 18 +-- lib/features/intro/intro_page.dart | 145 ++++++++++++------------ lib/utils/bottom_sheet_page.dart | 2 +- 5 files changed, 105 insertions(+), 93 deletions(-) diff --git a/lib/features/common/nested_app_bar.dart b/lib/features/common/nested_app_bar.dart index 99b3c1b3..0d872532 100644 --- a/lib/features/common/nested_app_bar.dart +++ b/lib/features/common/nested_app_bar.dart @@ -6,7 +6,8 @@ import 'package:hiddify/features/common/adaptive_root_scaffold.dart'; bool showDrawerButton(BuildContext context) { if (!useMobileRouter) return true; final String location = GoRouterState.of(context).uri.path; - if (location == const HomeRoute().location) return true; + if (location == const HomeRoute().location || + location == const ProfilesRoute().location) return true; if (location.startsWith(const ProxiesRoute().location)) return true; return false; } diff --git a/lib/features/common/profile_tile.dart b/lib/features/common/profile_tile.dart index 22073d41..b33f8c2a 100644 --- a/lib/features/common/profile_tile.dart +++ b/lib/features/common/profile_tile.dart @@ -345,21 +345,27 @@ class ProfileSubscriptionInfo extends HookConsumerWidget { children: [ Directionality( textDirection: TextDirection.ltr, - child: Text( - subInfo.total > 10 * 1099511627776 //10TB - ? "∞ GiB" - : subInfo.consumption.sizeOf(subInfo.total), - semanticsLabel: - t.profile.subscription.remainingTrafficSemanticLabel( - consumed: subInfo.consumption.sizeGB(), - total: subInfo.total.sizeGB(), + child: Flexible( + child: Text( + subInfo.total > 10 * 1099511627776 //10TB + ? "∞ GiB" + : subInfo.consumption.sizeOf(subInfo.total), + semanticsLabel: + t.profile.subscription.remainingTrafficSemanticLabel( + consumed: subInfo.consumption.sizeGB(), + total: subInfo.total.sizeGB(), + ), + style: theme.textTheme.bodySmall, + overflow: TextOverflow.ellipsis, ), - style: theme.textTheme.bodySmall, ), ), - Text( - remaining.$1, - style: theme.textTheme.bodySmall?.copyWith(color: remaining.$2), + Flexible( + child: Text( + remaining.$1, + style: theme.textTheme.bodySmall?.copyWith(color: remaining.$2), + overflow: TextOverflow.ellipsis, + ), ), ], ); diff --git a/lib/features/home/view/home_page.dart b/lib/features/home/view/home_page.dart index 2ce3e82d..e3ed99ba 100644 --- a/lib/features/home/view/home_page.dart +++ b/lib/features/home/view/home_page.dart @@ -1,6 +1,5 @@ import 'package:dartx/dartx.dart'; import 'package:flutter/material.dart'; -import 'package:gap/gap.dart'; import 'package:hiddify/core/core_providers.dart'; import 'package:hiddify/core/router/router.dart'; import 'package:hiddify/domain/failures.dart'; @@ -30,12 +29,17 @@ class HomePage extends HookConsumerWidget { CustomScrollView( slivers: [ NestedAppBar( - title: Row( - children: [ - Text(t.general.appTitle), - const Gap(4), - const AppVersionLabel(), - ], + title: Text.rich( + TextSpan( + children: [ + TextSpan(text: t.general.appTitle), + const TextSpan(text: " "), + const WidgetSpan( + child: AppVersionLabel(), + alignment: PlaceholderAlignment.middle, + ), + ], + ), ), actions: [ IconButton( diff --git a/lib/features/intro/intro_page.dart b/lib/features/intro/intro_page.dart index c2d926fa..53da7370 100644 --- a/lib/features/intro/intro_page.dart +++ b/lib/features/intro/intro_page.dart @@ -21,86 +21,87 @@ class IntroPage extends HookConsumerWidget with PresLogger { final isStarting = useState(false); - return Scaffold( - body: CustomScrollView( - shrinkWrap: true, - slivers: [ - const SliverGap(24), - SliverToBoxAdapter( - child: SizedBox( - width: 248, - height: 248, - child: Padding( - padding: const EdgeInsets.all(36), - child: Assets.images.logo.svg(), + return SafeArea( + child: Scaffold( + body: CustomScrollView( + shrinkWrap: true, + slivers: [ + SliverToBoxAdapter( + child: SizedBox( + width: 224, + height: 224, + child: Padding( + padding: const EdgeInsets.all(24), + child: Assets.images.logo.svg(), + ), ), ), - ), - SliverCrossAxisConstrained( - maxCrossAxisExtent: 368, - child: MultiSliver( - children: [ - const LocalePrefTile(), - const SliverGap(8), - const RegionPrefTile(), - const SliverGap(8), - const EnableAnalyticsPrefTile(), - const SliverGap(8), - Padding( - padding: const EdgeInsets.symmetric(horizontal: 16), - child: Text.rich( - t.intro.termsAndPolicyCaution( - tap: (text) => TextSpan( - text: text, - style: const TextStyle(color: Colors.blue), - recognizer: TapGestureRecognizer() - ..onTap = () async { - await UriUtils.tryLaunch( - Uri.parse(Constants.termsAndConditionsUrl), - ); - }, + SliverCrossAxisConstrained( + maxCrossAxisExtent: 368, + child: MultiSliver( + children: [ + const LocalePrefTile(), + const SliverGap(4), + const RegionPrefTile(), + const SliverGap(4), + const EnableAnalyticsPrefTile(), + const SliverGap(4), + Padding( + padding: const EdgeInsets.symmetric(horizontal: 16), + child: Text.rich( + t.intro.termsAndPolicyCaution( + tap: (text) => TextSpan( + text: text, + style: const TextStyle(color: Colors.blue), + recognizer: TapGestureRecognizer() + ..onTap = () async { + await UriUtils.tryLaunch( + Uri.parse(Constants.termsAndConditionsUrl), + ); + }, + ), ), + style: Theme.of(context).textTheme.bodySmall, ), - style: Theme.of(context).textTheme.bodySmall, ), - ), - Padding( - padding: const EdgeInsets.symmetric( - horizontal: 16, - vertical: 24, - ), - child: FilledButton( - onPressed: () async { - if (isStarting.value) return; - isStarting.value = true; - if (!ref.read(enableAnalyticsProvider)) { - loggy.info("disabling analytics per user request"); - try { - await Sentry.close(); - } catch (error, stackTrace) { - loggy.error( - "could not disable analytics", - error, - stackTrace, - ); + Padding( + padding: const EdgeInsets.symmetric( + horizontal: 16, + vertical: 24, + ), + child: FilledButton( + onPressed: () async { + if (isStarting.value) return; + isStarting.value = true; + if (!ref.read(enableAnalyticsProvider)) { + loggy.info("disabling analytics per user request"); + try { + await Sentry.close(); + } catch (error, stackTrace) { + loggy.error( + "could not disable analytics", + error, + stackTrace, + ); + } } - } - await ref - .read(introCompletedProvider.notifier) - .update(true); - }, - child: isStarting.value - ? LinearProgressIndicator( - backgroundColor: Colors.transparent, - color: Theme.of(context).colorScheme.onSurface, - ) - : Text(t.intro.start), + await ref + .read(introCompletedProvider.notifier) + .update(true); + }, + child: isStarting.value + ? LinearProgressIndicator( + backgroundColor: Colors.transparent, + color: Theme.of(context).colorScheme.onSurface, + ) + : Text(t.intro.start), + ), ), - ), - ], + ], + ), ), - ), - ], + ], + ), ), ); } diff --git a/lib/utils/bottom_sheet_page.dart b/lib/utils/bottom_sheet_page.dart index 659301f6..1470383e 100644 --- a/lib/utils/bottom_sheet_page.dart +++ b/lib/utils/bottom_sheet_page.dart @@ -15,7 +15,7 @@ class BottomSheetPage extends Page { Route createRoute(BuildContext context) { return ModalBottomSheetRoute( settings: this, - isScrollControlled: !fixed, + isScrollControlled: true, useSafeArea: true, showDragHandle: true, builder: (_) {