From a0e1e9922348f49434d076163cf1ed85a32d417d Mon Sep 17 00:00:00 2001 From: Shawn Date: Mon, 23 Jan 2023 08:42:21 -0700 Subject: [PATCH 1/4] Remember selected wonder on the home page when relaunching app Version bump --- lib/logic/settings_logic.dart | 3 +++ lib/ui/screens/home/wonders_home_screen.dart | 26 ++++++++++++++------ pubspec.yaml | 2 +- release_notes.txt | 4 +-- 4 files changed, 25 insertions(+), 10 deletions(-) diff --git a/lib/logic/settings_logic.dart b/lib/logic/settings_logic.dart index f425cb26..b9dddc50 100644 --- a/lib/logic/settings_logic.dart +++ b/lib/logic/settings_logic.dart @@ -9,6 +9,7 @@ class SettingsLogic with ThrottledSaveLoadMixin { late final hasCompletedOnboarding = ValueNotifier(false)..addListener(scheduleSave); late final hasDismissedSearchMessage = ValueNotifier(false)..addListener(scheduleSave); late final currentLocale = ValueNotifier(null)..addListener(scheduleSave); + late final currentWonder = ValueNotifier(null)..addListener(scheduleSave); final bool useBlurs = !PlatformInfo.isAndroid; @@ -17,6 +18,7 @@ class SettingsLogic with ThrottledSaveLoadMixin { hasCompletedOnboarding.value = value['hasCompletedOnboarding'] ?? false; hasDismissedSearchMessage.value = value['hasDismissedSearchMessage'] ?? false; currentLocale.value = value['currentLocale']; + currentWonder.value = value['currentWonder']; } @override @@ -25,6 +27,7 @@ class SettingsLogic with ThrottledSaveLoadMixin { 'hasCompletedOnboarding': hasCompletedOnboarding.value, 'hasDismissedSearchMessage': hasDismissedSearchMessage.value, 'currentLocale': currentLocale.value, + 'currentWonder': currentWonder.value, }; } diff --git a/lib/ui/screens/home/wonders_home_screen.dart b/lib/ui/screens/home/wonders_home_screen.dart index 9008358c..2b9fd1df 100644 --- a/lib/ui/screens/home/wonders_home_screen.dart +++ b/lib/ui/screens/home/wonders_home_screen.dart @@ -25,10 +25,7 @@ class HomeScreen extends StatefulWidget with GetItStatefulWidgetMixin { /// Shows a horizontally scrollable list PageView sandwiched between Foreground and Background layers /// arranged in a parallax style. class _HomeScreenState extends State with SingleTickerProviderStateMixin { - late final _pageController = PageController( - viewportFraction: 1, - initialPage: _numWonders * 9999, // allow 'infinite' scrolling by starting at a very high page - ); + late final _pageController; List get _wonders => wondersLogic.all; bool _isMenuOpen = false; @@ -53,8 +50,23 @@ class _HomeScreenState extends State with SingleTickerProviderStateM bool _isSelected(WonderType t) => t == currentWonder.type; - void _handlePageViewChanged(v) { - setState(() => _wonderIndex = v % _numWonders); + @override + void initState() { + super.initState(); + // Create page controller, + // allow 'infinite' scrolling by starting at a very high page, or remember the previous value + final previousWonder = settingsLogic.currentWonder.value; + final initialPage = previousWonder ?? _numWonders * 9999; + _pageController = PageController(viewportFraction: 1, initialPage: initialPage); + _wonderIndex = initialPage % _numWonders; + } + + void _handlePageChanged(value) { + setState(() { + _wonderIndex = value % _numWonders; + // Save current wonder for next launch + settingsLogic.currentWonder.value = value; + }); AppHaptics.lightImpact(); } @@ -142,7 +154,7 @@ class _HomeScreenState extends State with SingleTickerProviderStateM return ExcludeSemantics( child: PageView.builder( controller: _pageController, - onPageChanged: _handlePageViewChanged, + onPageChanged: _handlePageChanged, itemBuilder: (_, index) { final wonder = _wonders[index % _wonders.length]; final wonderType = wonder.type; diff --git a/pubspec.yaml b/pubspec.yaml index 46b942a9..bb44dd83 100644 --- a/pubspec.yaml +++ b/pubspec.yaml @@ -1,7 +1,7 @@ name: wonders description: Explore the famous wonders of the world. publish_to: "none" -version: 2.0.8 +version: 2.0.9 environment: sdk: ">=2.17.0 <3.0.0" diff --git a/release_notes.txt b/release_notes.txt index e9a24029..f2407c7a 100644 --- a/release_notes.txt +++ b/release_notes.txt @@ -1,2 +1,2 @@ -# 2.0.8 -- Styling polish / fixes \ No newline at end of file +# 2.0.9 +- Remember currently selected wonder on home page \ No newline at end of file From 13073d4e0263d6d32309fcc48d1b3ed8e1c4bb7e Mon Sep 17 00:00:00 2001 From: Shawn Date: Mon, 23 Jan 2023 09:07:30 -0700 Subject: [PATCH 2/4] EventsView: switch to two-column layout at aspect ratios > .85 --- lib/ui/screens/wonder_events/wonder_events.dart | 16 ++++++++++++---- release_notes.txt | 3 ++- 2 files changed, 14 insertions(+), 5 deletions(-) diff --git a/lib/ui/screens/wonder_events/wonder_events.dart b/lib/ui/screens/wonder_events/wonder_events.dart index ea56adac..e6f7af15 100644 --- a/lib/ui/screens/wonder_events/wonder_events.dart +++ b/lib/ui/screens/wonder_events/wonder_events.dart @@ -1,4 +1,7 @@ +import 'dart:io'; + import 'package:wonders/common_libs.dart'; +import 'package:wonders/logic/common/platform_info.dart'; import 'package:wonders/logic/common/string_utils.dart'; import 'package:wonders/logic/data/wonder_data.dart'; import 'package:wonders/ui/common/app_backdrop.dart'; @@ -26,6 +29,11 @@ class WonderEvents extends StatelessWidget { @override Widget build(BuildContext context) { void handleTimelineBtnPressed() => context.push(ScreenPaths.timeline(type)); + // Main view content switches between 1 and 2 column layouts + // On mobile, use the 2 column layout on screens close to landscape (>.85). This is primarily an optimization for foldable devices square-ish dimensions when opened. + final twoColumnAspect = PlatformInfo.isMobile ? .85 : 1; + bool useTwoColumnLayout = context.mq.size.aspectRatio > twoColumnAspect; + return LayoutBuilder(builder: (context, constraints) { return Container( color: $styles.colors.black, @@ -33,10 +41,10 @@ class WonderEvents extends StatelessWidget { bottom: false, child: Stack( children: [ - /// Main view switches between portrait and landscape views + /// Main view Positioned.fill( top: $styles.insets.sm, - child: context.isLandscape ? _buildLandscape(context) : _buildPortrait(), + child: useTwoColumnLayout ? _buildTwoColumn(context) : _buildSingleColumn(), ), /// Header w/ TimelineBtn @@ -58,7 +66,7 @@ class WonderEvents extends StatelessWidget { } /// Landscape layout is a row, with the WonderImage on left and EventsList on the right - Widget _buildLandscape(BuildContext context) { + Widget _buildTwoColumn(BuildContext context) { return Row( children: [ /// WonderImage w/ Timeline btn @@ -104,7 +112,7 @@ class WonderEvents extends StatelessWidget { } /// Portrait layout is a stack with the EventsList scrolling overtop of the WonderImage - Widget _buildPortrait() { + Widget _buildSingleColumn() { return LayoutBuilder(builder: (_, constraints) { double topHeight = max(constraints.maxHeight * .55, 200); return CenteredBox( diff --git a/release_notes.txt b/release_notes.txt index f2407c7a..c6525973 100644 --- a/release_notes.txt +++ b/release_notes.txt @@ -1,2 +1,3 @@ # 2.0.9 -- Remember currently selected wonder on home page \ No newline at end of file +- Remember currently selected wonder on home page +- EventsView: switch to two-column layout at aspect ratios > .85 From 849923d739d27a191e87197e7229acf8b3dee4b3 Mon Sep 17 00:00:00 2001 From: Shawn Date: Mon, 23 Jan 2023 09:46:01 -0700 Subject: [PATCH 3/4] Small tweaks for intro screen on foldable --- lib/ui/screens/intro/intro_screen.dart | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/lib/ui/screens/intro/intro_screen.dart b/lib/ui/screens/intro/intro_screen.dart index 1a46c026..2322abb1 100644 --- a/lib/ui/screens/intro/intro_screen.dart +++ b/lib/ui/screens/intro/intro_screen.dart @@ -15,9 +15,9 @@ class IntroScreen extends StatefulWidget { } class _IntroScreenState extends State { - static const double _imageSize = 264; + static const double _imageSize = 250; static const double _logoHeight = 126; - static const double _textHeight = 155; + static const double _textHeight = 100; static const double _pageIndicatorHeight = 55; static List<_PageData> pageData = []; @@ -132,7 +132,7 @@ class _IntroScreenState extends State { // page indicator: Container( height: _pageIndicatorHeight, - alignment: Alignment(0.0, -0.75), + alignment: Alignment(0.0, 0), child: AppPageIndicator( count: pageData.length, controller: _pageController, color: $styles.colors.offWhite), ), From f81797dda1a906ef4c1caafaa7cb77cd4f3aa1c9 Mon Sep 17 00:00:00 2001 From: Shawn Date: Mon, 23 Jan 2023 10:20:42 -0700 Subject: [PATCH 4/4] Version bump --- pubspec.yaml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pubspec.yaml b/pubspec.yaml index bb44dd83..e90f9f59 100644 --- a/pubspec.yaml +++ b/pubspec.yaml @@ -1,7 +1,7 @@ name: wonders description: Explore the famous wonders of the world. publish_to: "none" -version: 2.0.9 +version: 2.0.9+1 environment: sdk: ">=2.17.0 <3.0.0"