mirror of
https://github.com/foss42/apidash.git
synced 2025-12-04 03:46:57 +08:00
feat: add onboarding functionality and theme switch button
This commit is contained in:
@@ -1,3 +1,5 @@
|
||||
import 'package:apidash/screens/mobile/onboarding_screen.dart';
|
||||
import 'package:apidash/services/shared_preferences_services.dart';
|
||||
import 'package:apidash_design_system/apidash_design_system.dart';
|
||||
import 'package:flutter/material.dart';
|
||||
import 'package:flutter/services.dart';
|
||||
@@ -19,41 +21,50 @@ class MobileDashboard extends ConsumerStatefulWidget {
|
||||
}
|
||||
|
||||
class _MobileDashboardState extends ConsumerState<MobileDashboard> {
|
||||
@override
|
||||
Widget build(
|
||||
BuildContext context,
|
||||
) {
|
||||
final railIdx = ref.watch(navRailIndexStateProvider);
|
||||
final isLeftDrawerOpen = ref.watch(leftDrawerStateProvider);
|
||||
Future<bool> _checkOnboardingStatus() async {
|
||||
return await getOnboardingStatusFromSharedPrefs();
|
||||
}
|
||||
|
||||
return AnnotatedRegion<SystemUiOverlayStyle>(
|
||||
value: FlexColorScheme.themedSystemNavigationBar(
|
||||
context,
|
||||
opacity: 0,
|
||||
noAppBar: true,
|
||||
),
|
||||
child: Stack(
|
||||
alignment: AlignmentDirectional.bottomCenter,
|
||||
children: [
|
||||
PageBranch(
|
||||
pageIndex: railIdx,
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
return FutureBuilder<bool>(
|
||||
future: _checkOnboardingStatus(),
|
||||
builder: (context, snapshot) {
|
||||
final railIdx = ref.watch(navRailIndexStateProvider);
|
||||
final isLeftDrawerOpen = ref.watch(leftDrawerStateProvider);
|
||||
if (snapshot.connectionState == ConnectionState.waiting) {
|
||||
return const Center(child: CircularProgressIndicator());
|
||||
} else if (snapshot.data == false) {
|
||||
return const OnboardingScreen();
|
||||
}
|
||||
return AnnotatedRegion<SystemUiOverlayStyle>(
|
||||
value: FlexColorScheme.themedSystemNavigationBar(
|
||||
context,
|
||||
opacity: 0,
|
||||
noAppBar: true,
|
||||
),
|
||||
if (context.isMediumWindow)
|
||||
AnimatedPositioned(
|
||||
bottom: railIdx > 2
|
||||
? 0
|
||||
: isLeftDrawerOpen
|
||||
child: Stack(
|
||||
alignment: AlignmentDirectional.bottomCenter,
|
||||
children: [
|
||||
PageBranch(pageIndex: railIdx),
|
||||
if (context.isMediumWindow)
|
||||
AnimatedPositioned(
|
||||
bottom: railIdx > 2
|
||||
? 0
|
||||
: -(72 + MediaQuery.paddingOf(context).bottom),
|
||||
left: 0,
|
||||
right: 0,
|
||||
height: 70 + MediaQuery.paddingOf(context).bottom,
|
||||
duration: const Duration(milliseconds: 200),
|
||||
curve: Curves.easeOut,
|
||||
child: const BottomNavBar(),
|
||||
),
|
||||
],
|
||||
),
|
||||
: isLeftDrawerOpen
|
||||
? 0
|
||||
: -(72 + MediaQuery.paddingOf(context).bottom),
|
||||
left: 0,
|
||||
right: 0,
|
||||
height: 70 + MediaQuery.paddingOf(context).bottom,
|
||||
duration: const Duration(milliseconds: 200),
|
||||
curve: Curves.easeOut,
|
||||
child: const BottomNavBar(),
|
||||
),
|
||||
],
|
||||
),
|
||||
);
|
||||
},
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user