Fix ui bugs

This commit is contained in:
problematicconsumer
2023-11-10 15:35:44 +03:30
parent e5166d3183
commit b9eae35fda
5 changed files with 105 additions and 93 deletions

View File

@@ -6,7 +6,8 @@ import 'package:hiddify/features/common/adaptive_root_scaffold.dart';
bool showDrawerButton(BuildContext context) { bool showDrawerButton(BuildContext context) {
if (!useMobileRouter) return true; if (!useMobileRouter) return true;
final String location = GoRouterState.of(context).uri.path; 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; if (location.startsWith(const ProxiesRoute().location)) return true;
return false; return false;
} }

View File

@@ -345,21 +345,27 @@ class ProfileSubscriptionInfo extends HookConsumerWidget {
children: [ children: [
Directionality( Directionality(
textDirection: TextDirection.ltr, textDirection: TextDirection.ltr,
child: Text( child: Flexible(
subInfo.total > 10 * 1099511627776 //10TB child: Text(
? "∞ GiB" subInfo.total > 10 * 1099511627776 //10TB
: subInfo.consumption.sizeOf(subInfo.total), ? "∞ GiB"
semanticsLabel: : subInfo.consumption.sizeOf(subInfo.total),
t.profile.subscription.remainingTrafficSemanticLabel( semanticsLabel:
consumed: subInfo.consumption.sizeGB(), t.profile.subscription.remainingTrafficSemanticLabel(
total: subInfo.total.sizeGB(), consumed: subInfo.consumption.sizeGB(),
total: subInfo.total.sizeGB(),
),
style: theme.textTheme.bodySmall,
overflow: TextOverflow.ellipsis,
), ),
style: theme.textTheme.bodySmall,
), ),
), ),
Text( Flexible(
remaining.$1, child: Text(
style: theme.textTheme.bodySmall?.copyWith(color: remaining.$2), remaining.$1,
style: theme.textTheme.bodySmall?.copyWith(color: remaining.$2),
overflow: TextOverflow.ellipsis,
),
), ),
], ],
); );

View File

@@ -1,6 +1,5 @@
import 'package:dartx/dartx.dart'; import 'package:dartx/dartx.dart';
import 'package:flutter/material.dart'; import 'package:flutter/material.dart';
import 'package:gap/gap.dart';
import 'package:hiddify/core/core_providers.dart'; import 'package:hiddify/core/core_providers.dart';
import 'package:hiddify/core/router/router.dart'; import 'package:hiddify/core/router/router.dart';
import 'package:hiddify/domain/failures.dart'; import 'package:hiddify/domain/failures.dart';
@@ -30,12 +29,17 @@ class HomePage extends HookConsumerWidget {
CustomScrollView( CustomScrollView(
slivers: [ slivers: [
NestedAppBar( NestedAppBar(
title: Row( title: Text.rich(
children: [ TextSpan(
Text(t.general.appTitle), children: [
const Gap(4), TextSpan(text: t.general.appTitle),
const AppVersionLabel(), const TextSpan(text: " "),
], const WidgetSpan(
child: AppVersionLabel(),
alignment: PlaceholderAlignment.middle,
),
],
),
), ),
actions: [ actions: [
IconButton( IconButton(

View File

@@ -21,86 +21,87 @@ class IntroPage extends HookConsumerWidget with PresLogger {
final isStarting = useState(false); final isStarting = useState(false);
return Scaffold( return SafeArea(
body: CustomScrollView( child: Scaffold(
shrinkWrap: true, body: CustomScrollView(
slivers: [ shrinkWrap: true,
const SliverGap(24), slivers: [
SliverToBoxAdapter( SliverToBoxAdapter(
child: SizedBox( child: SizedBox(
width: 248, width: 224,
height: 248, height: 224,
child: Padding( child: Padding(
padding: const EdgeInsets.all(36), padding: const EdgeInsets.all(24),
child: Assets.images.logo.svg(), child: Assets.images.logo.svg(),
),
), ),
), ),
), SliverCrossAxisConstrained(
SliverCrossAxisConstrained( maxCrossAxisExtent: 368,
maxCrossAxisExtent: 368, child: MultiSliver(
child: MultiSliver( children: [
children: [ const LocalePrefTile(),
const LocalePrefTile(), const SliverGap(4),
const SliverGap(8), const RegionPrefTile(),
const RegionPrefTile(), const SliverGap(4),
const SliverGap(8), const EnableAnalyticsPrefTile(),
const EnableAnalyticsPrefTile(), const SliverGap(4),
const SliverGap(8), Padding(
Padding( padding: const EdgeInsets.symmetric(horizontal: 16),
padding: const EdgeInsets.symmetric(horizontal: 16), child: Text.rich(
child: Text.rich( t.intro.termsAndPolicyCaution(
t.intro.termsAndPolicyCaution( tap: (text) => TextSpan(
tap: (text) => TextSpan( text: text,
text: text, style: const TextStyle(color: Colors.blue),
style: const TextStyle(color: Colors.blue), recognizer: TapGestureRecognizer()
recognizer: TapGestureRecognizer() ..onTap = () async {
..onTap = () async { await UriUtils.tryLaunch(
await UriUtils.tryLaunch( Uri.parse(Constants.termsAndConditionsUrl),
Uri.parse(Constants.termsAndConditionsUrl), );
); },
}, ),
), ),
style: Theme.of(context).textTheme.bodySmall,
), ),
style: Theme.of(context).textTheme.bodySmall,
), ),
), Padding(
Padding( padding: const EdgeInsets.symmetric(
padding: const EdgeInsets.symmetric( horizontal: 16,
horizontal: 16, vertical: 24,
vertical: 24, ),
), child: FilledButton(
child: FilledButton( onPressed: () async {
onPressed: () async { if (isStarting.value) return;
if (isStarting.value) return; isStarting.value = true;
isStarting.value = true; if (!ref.read(enableAnalyticsProvider)) {
if (!ref.read(enableAnalyticsProvider)) { loggy.info("disabling analytics per user request");
loggy.info("disabling analytics per user request"); try {
try { await Sentry.close();
await Sentry.close(); } catch (error, stackTrace) {
} catch (error, stackTrace) { loggy.error(
loggy.error( "could not disable analytics",
"could not disable analytics", error,
error, stackTrace,
stackTrace, );
); }
} }
} await ref
await ref .read(introCompletedProvider.notifier)
.read(introCompletedProvider.notifier) .update(true);
.update(true); },
}, child: isStarting.value
child: isStarting.value ? LinearProgressIndicator(
? LinearProgressIndicator( backgroundColor: Colors.transparent,
backgroundColor: Colors.transparent, color: Theme.of(context).colorScheme.onSurface,
color: Theme.of(context).colorScheme.onSurface, )
) : Text(t.intro.start),
: Text(t.intro.start), ),
), ),
), ],
], ),
), ),
), ],
], ),
), ),
); );
} }

View File

@@ -15,7 +15,7 @@ class BottomSheetPage extends Page {
Route<void> createRoute(BuildContext context) { Route<void> createRoute(BuildContext context) {
return ModalBottomSheetRoute( return ModalBottomSheetRoute(
settings: this, settings: this,
isScrollControlled: !fixed, isScrollControlled: true,
useSafeArea: true, useSafeArea: true,
showDragHandle: true, showDragHandle: true,
builder: (_) { builder: (_) {