feat: add intro screen
This commit is contained in:
@@ -1,5 +1,6 @@
|
||||
import 'package:flutter/material.dart';
|
||||
import 'package:go_router/go_router.dart';
|
||||
import 'package:hiddify/core/prefs/prefs.dart';
|
||||
import 'package:hiddify/core/router/routes/routes.dart';
|
||||
import 'package:hiddify/services/deep_link_service.dart';
|
||||
import 'package:riverpod_annotation/riverpod_annotation.dart';
|
||||
@@ -9,6 +10,7 @@ part 'app_router.g.dart';
|
||||
// TODO: test and improve handling of deep link
|
||||
@riverpod
|
||||
GoRouter router(RouterRef ref) {
|
||||
final introCompleted = ref.watch(introCompletedProvider);
|
||||
final deepLink = ref.listen(
|
||||
deepLinkServiceProvider,
|
||||
(_, next) async {
|
||||
@@ -28,6 +30,12 @@ GoRouter router(RouterRef ref) {
|
||||
initialLocation: initialLocation,
|
||||
debugLogDiagnostics: true,
|
||||
routes: $routes,
|
||||
redirect: (context, state) {
|
||||
if (!introCompleted && state.uri.path != const IntroRoute().location) {
|
||||
return const IntroRoute().location;
|
||||
}
|
||||
return null;
|
||||
},
|
||||
);
|
||||
}
|
||||
|
||||
|
||||
@@ -1,12 +1,14 @@
|
||||
import 'package:go_router/go_router.dart';
|
||||
import 'package:hiddify/core/router/routes/desktop_routes.dart' as desktop;
|
||||
import 'package:hiddify/core/router/routes/mobile_routes.dart' as mobile;
|
||||
import 'package:hiddify/core/router/routes/shared_routes.dart' as shared;
|
||||
import 'package:hiddify/utils/utils.dart';
|
||||
|
||||
export 'mobile_routes.dart';
|
||||
export 'shared_routes.dart';
|
||||
export 'shared_routes.dart' hide $appRoutes;
|
||||
|
||||
List<RouteBase> get $routes => [
|
||||
...shared.$appRoutes,
|
||||
if (PlatformUtils.isDesktop)
|
||||
...desktop.$appRoutes
|
||||
else
|
||||
|
||||
@@ -1,11 +1,14 @@
|
||||
import 'package:flutter/material.dart';
|
||||
import 'package:go_router/go_router.dart';
|
||||
import 'package:hiddify/features/home/view/view.dart';
|
||||
import 'package:hiddify/features/intro/view/view.dart';
|
||||
import 'package:hiddify/features/profile_detail/view/view.dart';
|
||||
import 'package:hiddify/features/profiles/view/view.dart';
|
||||
import 'package:hiddify/features/proxies/view/view.dart';
|
||||
import 'package:hiddify/utils/utils.dart';
|
||||
|
||||
part 'shared_routes.g.dart';
|
||||
|
||||
final GlobalKey<NavigatorState> rootNavigatorKey = GlobalKey<NavigatorState>();
|
||||
|
||||
class HomeRoute extends GoRouteData {
|
||||
@@ -47,6 +50,20 @@ class AddProfileRoute extends GoRouteData {
|
||||
}
|
||||
}
|
||||
|
||||
@TypedGoRoute<IntroRoute>(path: IntroRoute.path)
|
||||
class IntroRoute extends GoRouteData {
|
||||
const IntroRoute();
|
||||
static const path = '/intro';
|
||||
|
||||
@override
|
||||
Page<void> buildPage(BuildContext context, GoRouterState state) {
|
||||
return const MaterialPage(
|
||||
fullscreenDialog: true,
|
||||
child: IntroPage(),
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
class ProfilesRoute extends GoRouteData {
|
||||
const ProfilesRoute();
|
||||
static const path = 'profiles';
|
||||
|
||||
66
lib/features/intro/view/intro_page.dart
Normal file
66
lib/features/intro/view/intro_page.dart
Normal file
@@ -0,0 +1,66 @@
|
||||
import 'package:flutter/material.dart';
|
||||
import 'package:gap/gap.dart';
|
||||
import 'package:hiddify/core/core_providers.dart';
|
||||
import 'package:hiddify/core/prefs/prefs.dart';
|
||||
import 'package:hiddify/features/common/common.dart';
|
||||
import 'package:hiddify/gen/assets.gen.dart';
|
||||
import 'package:hiddify/utils/utils.dart';
|
||||
import 'package:hooks_riverpod/hooks_riverpod.dart';
|
||||
import 'package:sentry_flutter/sentry_flutter.dart';
|
||||
import 'package:sliver_tools/sliver_tools.dart';
|
||||
|
||||
class IntroPage extends HookConsumerWidget with PresLogger {
|
||||
const IntroPage({super.key});
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context, WidgetRef ref) {
|
||||
final t = ref.watch(translationsProvider);
|
||||
|
||||
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(),
|
||||
),
|
||||
),
|
||||
),
|
||||
SliverCrossAxisConstrained(
|
||||
maxCrossAxisExtent: 368,
|
||||
child: MultiSliver(
|
||||
children: [
|
||||
const LocalePrefTile(),
|
||||
const SliverGap(8),
|
||||
const EnableAnalyticsPrefTile(),
|
||||
Padding(
|
||||
padding: const EdgeInsets.symmetric(
|
||||
horizontal: 16,
|
||||
vertical: 24,
|
||||
),
|
||||
child: FilledButton(
|
||||
onPressed: () async {
|
||||
if (!ref.read(enableAnalyticsProvider)) {
|
||||
loggy.debug("disabling analytics per user request");
|
||||
await Sentry.close();
|
||||
}
|
||||
await ref
|
||||
.read(introCompletedProvider.notifier)
|
||||
.update(true);
|
||||
},
|
||||
child: Text(t.intro.start),
|
||||
),
|
||||
),
|
||||
],
|
||||
),
|
||||
),
|
||||
],
|
||||
),
|
||||
);
|
||||
}
|
||||
}
|
||||
1
lib/features/intro/view/view.dart
Normal file
1
lib/features/intro/view/view.dart
Normal file
@@ -0,0 +1 @@
|
||||
export 'intro_page.dart';
|
||||
Reference in New Issue
Block a user