From b4d87978e2c9fa5349bf2bb6a2a80dbe59532c4e Mon Sep 17 00:00:00 2001 From: Armand <4831c0@proton.me> Date: Sat, 13 Sep 2025 13:36:08 +0200 Subject: [PATCH] settings & home: use firka app bundle fixes #61 --- .../ui/phone/screens/home/home_screen.dart | 353 +++++++++--------- .../screens/settings/settings_screen.dart | 38 +- 2 files changed, 198 insertions(+), 193 deletions(-) diff --git a/firka/lib/ui/phone/screens/home/home_screen.dart b/firka/lib/ui/phone/screens/home/home_screen.dart index eb3d72a..ed0a003 100644 --- a/firka/lib/ui/phone/screens/home/home_screen.dart +++ b/firka/lib/ui/phone/screens/home/home_screen.dart @@ -377,192 +377,195 @@ class _HomeScreenState extends FirkaState { } SystemChrome.setEnabledSystemUIMode(SystemUiMode.edgeToEdge); - return PopScope( - canPop: canPop, - child: Scaffold( - backgroundColor: appStyle.colors.background, - body: SafeArea( - child: SizedBox( - height: MediaQuery.of(context).size.height, - child: Stack( - children: [ - Column( - mainAxisAlignment: MainAxisAlignment.spaceBetween, + return DefaultAssetBundle( + bundle: FirkaBundle(), + child: PopScope( + canPop: canPop, + child: Scaffold( + backgroundColor: appStyle.colors.background, + body: SafeArea( + child: SizedBox( + height: MediaQuery.of(context).size.height, + child: Stack( children: [ - Expanded( - child: RefreshConfiguration( - springDescription: SpringDescription( - mass: 1.9, stiffness: 85, damping: 16), - child: SmartScroll( - controller: _refreshController, - onLoading: _onLoading, - onRefresh: _onRefresh, - header: MaterialClassicHeader( - color: appStyle.colors.accent, - backgroundColor: appStyle.colors.background, - offset: 24, - ), - physics: ClampingScrollPhysics(), - child: PageView( - controller: _pageController, - physics: ClampingScrollPhysics(), - onPageChanged: (index) { - HapticFeedback.heavyImpact(); - - if (forcedNav > 0) { - forcedNav--; - - if (previousPages.isEmpty) { - canPop = true; - } - return; - } - - setState(() { - previousPages.add(page); - canPop = false; - page = HomePage.values[index]; - }); - }, - children: [ - HomeSubPage( - HomePage.home, - widget.data, - widget.updateNotifier, - widget.updateFinishedNotifier, + Column( + mainAxisAlignment: MainAxisAlignment.spaceBetween, + children: [ + Expanded( + child: RefreshConfiguration( + springDescription: SpringDescription( + mass: 1.9, stiffness: 85, damping: 16), + child: SmartScroll( + controller: _refreshController, + onLoading: _onLoading, + onRefresh: _onRefresh, + header: MaterialClassicHeader( + color: appStyle.colors.accent, + backgroundColor: appStyle.colors.background, + offset: 24, ), - HomeSubPage( - HomePage.grades, - widget.data, - widget.updateNotifier, - widget.updateFinishedNotifier, - ), - HomeSubPage( - HomePage.timetable, - widget.data, - widget.updateNotifier, - widget.updateFinishedNotifier, - ), - ], - ))), - ), - Container( - decoration: BoxDecoration( - gradient: LinearGradient( - begin: Alignment.bottomCenter, - end: Alignment.topCenter, - colors: [ - appStyle.colors.background, - appStyle.colors.background.withValues(alpha: 0.0), - ], - stops: const [0.0, 1.0], + physics: ClampingScrollPhysics(), + child: PageView( + controller: _pageController, + physics: ClampingScrollPhysics(), + onPageChanged: (index) { + HapticFeedback.heavyImpact(); + + if (forcedNav > 0) { + forcedNav--; + + if (previousPages.isEmpty) { + canPop = true; + } + return; + } + + setState(() { + previousPages.add(page); + canPop = false; + page = HomePage.values[index]; + }); + }, + children: [ + HomeSubPage( + HomePage.home, + widget.data, + widget.updateNotifier, + widget.updateFinishedNotifier, + ), + HomeSubPage( + HomePage.grades, + widget.data, + widget.updateNotifier, + widget.updateFinishedNotifier, + ), + HomeSubPage( + HomePage.timetable, + widget.data, + widget.updateNotifier, + widget.updateFinishedNotifier, + ), + ], + ))), ), - ), - width: MediaQuery.of(context).size.width, - child: Padding( - padding: const EdgeInsets.symmetric( - horizontal: 55, vertical: 15), - child: Row( - mainAxisAlignment: MainAxisAlignment.spaceBetween, - children: [ - // Home Button - BottomNavIconWidget(() { - if (page != HomePage.home) { - _pageController.animateToPage( - HomePage.home.index, - duration: Duration(milliseconds: 175), - curve: Curves.easeInOut, - ); - } - }, - page == HomePage.home, - page == HomePage.home - ? Majesticon.homeSolid - : Majesticon.homeLine, - widget.data.l10n.home, - page == HomePage.home - ? appStyle.colors.accent - : appStyle.colors.secondary, - appStyle.colors.textPrimary), - // Grades Button - BottomNavIconWidget(() { - if (page != HomePage.grades) { - _pageController.animateToPage( - HomePage.grades.index, - duration: Duration(milliseconds: 175), - curve: Curves.easeInOut, - ); - } - }, - page == HomePage.grades, - page == HomePage.grades - ? Majesticon.bookmarkSolid - : Majesticon.bookmarkLine, - widget.data.l10n.grades, - page == HomePage.grades - ? appStyle.colors.accent - : appStyle.colors.secondary, - appStyle.colors.textPrimary), - // Timetable Button - BottomNavIconWidget(() { - if (page != HomePage.timetable) { - _pageController.animateToPage( - HomePage.timetable.index, - duration: Duration(milliseconds: 175), - curve: Curves.easeInOut, - ); - } - }, - page == HomePage.timetable, - page == HomePage.timetable - ? Majesticon.calendarSolid - : Majesticon.calendarLine, - widget.data.l10n.timetable, - page == HomePage.timetable - ? appStyle.colors.accent - : appStyle.colors.secondary, - appStyle.colors.textPrimary), - // More Button - BottomNavIconWidget( - () { - HapticFeedback.lightImpact(); - showExtrasBottomSheet(context, widget.data); - }, - false, - Majesticon.globeEarthLine, - widget.data.l10n.other, - appStyle.colors.secondary, - appStyle.colors.textPrimary, + Container( + decoration: BoxDecoration( + gradient: LinearGradient( + begin: Alignment.bottomCenter, + end: Alignment.topCenter, + colors: [ + appStyle.colors.background, + appStyle.colors.background + .withValues(alpha: 0.0), + ], + stops: const [0.0, 1.0], ), - ], + ), + width: MediaQuery.of(context).size.width, + child: Padding( + padding: const EdgeInsets.symmetric( + horizontal: 55, vertical: 15), + child: Row( + mainAxisAlignment: MainAxisAlignment.spaceBetween, + children: [ + // Home Button + BottomNavIconWidget(() { + if (page != HomePage.home) { + _pageController.animateToPage( + HomePage.home.index, + duration: Duration(milliseconds: 175), + curve: Curves.easeInOut, + ); + } + }, + page == HomePage.home, + page == HomePage.home + ? Majesticon.homeSolid + : Majesticon.homeLine, + widget.data.l10n.home, + page == HomePage.home + ? appStyle.colors.accent + : appStyle.colors.secondary, + appStyle.colors.textPrimary), + // Grades Button + BottomNavIconWidget(() { + if (page != HomePage.grades) { + _pageController.animateToPage( + HomePage.grades.index, + duration: Duration(milliseconds: 175), + curve: Curves.easeInOut, + ); + } + }, + page == HomePage.grades, + page == HomePage.grades + ? Majesticon.bookmarkSolid + : Majesticon.bookmarkLine, + widget.data.l10n.grades, + page == HomePage.grades + ? appStyle.colors.accent + : appStyle.colors.secondary, + appStyle.colors.textPrimary), + // Timetable Button + BottomNavIconWidget(() { + if (page != HomePage.timetable) { + _pageController.animateToPage( + HomePage.timetable.index, + duration: Duration(milliseconds: 175), + curve: Curves.easeInOut, + ); + } + }, + page == HomePage.timetable, + page == HomePage.timetable + ? Majesticon.calendarSolid + : Majesticon.calendarLine, + widget.data.l10n.timetable, + page == HomePage.timetable + ? appStyle.colors.accent + : appStyle.colors.secondary, + appStyle.colors.textPrimary), + // More Button + BottomNavIconWidget( + () { + HapticFeedback.lightImpact(); + showExtrasBottomSheet(context, widget.data); + }, + false, + Majesticon.globeEarthLine, + widget.data.l10n.other, + appStyle.colors.secondary, + appStyle.colors.textPrimary, + ), + ], + ), + ), ), - ), + ], ), + toast ?? SizedBox(), ], ), - toast ?? SizedBox(), - ], + ), ), ), - ), - ), - onPopInvokedWithResult: (_, __) => { - if (previousPages.isNotEmpty && page != previousPages.last) - { - setState(() { - page = previousPages.removeLast(); + onPopInvokedWithResult: (_, __) => { + if (previousPages.isNotEmpty && page != previousPages.last) + { + setState(() { + page = previousPages.removeLast(); - forcedNav++; - _pageController.animateToPage( - page.index, - duration: Duration(milliseconds: 175), - curve: Curves.easeInOut, - ); - canPop = previousPages.isEmpty; - }) - } - }, - ); + forcedNav++; + _pageController.animateToPage( + page.index, + duration: Duration(milliseconds: 175), + curve: Curves.easeInOut, + ); + canPop = previousPages.isEmpty; + }) + } + }, + )); } @override diff --git a/firka/lib/ui/phone/screens/settings/settings_screen.dart b/firka/lib/ui/phone/screens/settings/settings_screen.dart index 4f4aa17..3407561 100644 --- a/firka/lib/ui/phone/screens/settings/settings_screen.dart +++ b/firka/lib/ui/phone/screens/settings/settings_screen.dart @@ -668,25 +668,27 @@ class _SettingsScreenState extends FirkaState { Widget build(BuildContext context) { var body = createWidgetTree(widget.items.values, widget.data.settings); - return Scaffold( - backgroundColor: appStyle.colors.background, - body: SafeArea( - child: SizedBox( - height: MediaQuery.of(context).size.height, - child: Stack( - children: [ - Padding( - padding: EdgeInsetsGeometry.all(20), - child: SingleChildScrollView( - child: Column( - crossAxisAlignment: CrossAxisAlignment.start, - children: body)), - ) - ], + return DefaultAssetBundle( + bundle: FirkaBundle(), + child: Scaffold( + backgroundColor: appStyle.colors.background, + body: SafeArea( + child: SizedBox( + height: MediaQuery.of(context).size.height, + child: Stack( + children: [ + Padding( + padding: EdgeInsetsGeometry.all(20), + child: SingleChildScrollView( + child: Column( + crossAxisAlignment: CrossAxisAlignment.start, + children: body)), + ) + ], + ), + ), ), - ), - ), - ); + )); } }