Merge branch 'main' into ui-polish-4

This commit is contained in:
Jared Bell 2023-01-23 10:50:46 -07:00
commit c6db38cb09
6 changed files with 41 additions and 17 deletions

View File

@ -9,6 +9,7 @@ class SettingsLogic with ThrottledSaveLoadMixin {
late final hasCompletedOnboarding = ValueNotifier<bool>(false)..addListener(scheduleSave);
late final hasDismissedSearchMessage = ValueNotifier<bool>(false)..addListener(scheduleSave);
late final currentLocale = ValueNotifier<String?>(null)..addListener(scheduleSave);
late final currentWonder = ValueNotifier<int?>(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,
};
}

View File

@ -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<HomeScreen> 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<WonderData> get _wonders => wondersLogic.all;
bool _isMenuOpen = false;
@ -53,8 +50,23 @@ class _HomeScreenState extends State<HomeScreen> 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<HomeScreen> 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;

View File

@ -15,9 +15,9 @@ class IntroScreen extends StatefulWidget {
}
class _IntroScreenState extends State<IntroScreen> {
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<IntroScreen> {
// 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),
),

View File

@ -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(

View File

@ -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+1
environment:
sdk: ">=2.17.0 <3.0.0"

View File

@ -1,2 +1,3 @@
# 2.0.8
- Styling polish / fixes
# 2.0.9
- Remember currently selected wonder on home page
- EventsView: switch to two-column layout at aspect ratios > .85