Update line endings
This commit is contained in:
parent
a3e13de6ba
commit
9463be0bcd
@ -1,7 +1,6 @@
|
|||||||
import 'dart:async';
|
import 'dart:async';
|
||||||
|
|
||||||
import 'package:desktop_window/desktop_window.dart';
|
import 'package:desktop_window/desktop_window.dart';
|
||||||
import 'package:flutter/cupertino.dart';
|
|
||||||
import 'package:flutter_displaymode/flutter_displaymode.dart';
|
import 'package:flutter_displaymode/flutter_displaymode.dart';
|
||||||
import 'package:wonders/common_libs.dart';
|
import 'package:wonders/common_libs.dart';
|
||||||
import 'package:wonders/logic/common/platform_info.dart';
|
import 'package:wonders/logic/common/platform_info.dart';
|
||||||
@ -12,11 +11,12 @@ class AppLogic {
|
|||||||
/// The router will use this to prevent redirects while bootstrapping.
|
/// The router will use this to prevent redirects while bootstrapping.
|
||||||
bool isBootstrapComplete = false;
|
bool isBootstrapComplete = false;
|
||||||
|
|
||||||
bool get isDesktopOrTablet => PlatformInfo.isDesktopOrWeb || deviceSize.shortestSide > 480;
|
bool get isLandscapeEnabled =>
|
||||||
|
PlatformInfo.isDesktopOrWeb || deviceSize.shortestSide > 500;
|
||||||
|
|
||||||
/// Support portrait and landscape on desktop, web and tablets. Stick to portrait for phones.
|
/// Support portrait and landscape on desktop, web and tablets. Stick to portrait for phones.
|
||||||
/// A return value of null indicated both orientations are supported.
|
/// A return value of null indicated both orientations are supported.
|
||||||
Axis? get supportedOrientations => isDesktopOrTablet ? null : Axis.vertical;
|
Axis? get supportedOrientations => isLandscapeEnabled ? null : Axis.vertical;
|
||||||
|
|
||||||
Size get deviceSize {
|
Size get deviceSize {
|
||||||
final w = WidgetsBinding.instance.platformDispatcher.views.first;
|
final w = WidgetsBinding.instance.platformDispatcher.views.first;
|
||||||
@ -26,7 +26,8 @@ class AppLogic {
|
|||||||
/// Initialize the app and all main actors.
|
/// Initialize the app and all main actors.
|
||||||
/// Loads settings, sets up services etc.
|
/// Loads settings, sets up services etc.
|
||||||
Future<void> bootstrap() async {
|
Future<void> bootstrap() async {
|
||||||
debugPrint('bootstrap app, deviceSize: $deviceSize, isTablet: $isDesktopOrTablet');
|
debugPrint(
|
||||||
|
'bootstrap app, deviceSize: $deviceSize, isTablet: $isLandscapeEnabled');
|
||||||
|
|
||||||
// Set min-sizes for desktop apps
|
// Set min-sizes for desktop apps
|
||||||
if (PlatformInfo.isDesktop) {
|
if (PlatformInfo.isDesktop) {
|
||||||
@ -88,9 +89,10 @@ class AppLogic {
|
|||||||
SystemChrome.setPreferredOrientations(orientations);
|
SystemChrome.setPreferredOrientations(orientations);
|
||||||
}
|
}
|
||||||
|
|
||||||
Future<T?> showFullscreenDialogRoute<T>(BuildContext context, Widget child) async {
|
Future<T?> showFullscreenDialogRoute<T>(BuildContext context, Widget child,
|
||||||
|
{bool transparent = false}) async {
|
||||||
return await Navigator.of(context).push<T>(
|
return await Navigator.of(context).push<T>(
|
||||||
PageRoutes.dialog<T>(child, $styles.times.pageTransition),
|
PageRoutes.dialog<T>(child, duration: $styles.times.pageTransition),
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -18,7 +18,7 @@ class CollectibleItem extends StatelessWidget with GetItMixin {
|
|||||||
|
|
||||||
void _handleTap(BuildContext context) async {
|
void _handleTap(BuildContext context) async {
|
||||||
final screen = CollectibleFoundScreen(collectible: collectible, imageProvider: _imageProvider);
|
final screen = CollectibleFoundScreen(collectible: collectible, imageProvider: _imageProvider);
|
||||||
appLogic.showFullscreenDialogRoute(context, screen);
|
appLogic.showFullscreenDialogRoute(context, screen, transparent: true);
|
||||||
AppHaptics.mediumImpact();
|
AppHaptics.mediumImpact();
|
||||||
|
|
||||||
// wait to update the state, to ensure the hero works properly:
|
// wait to update the state, to ensure the hero works properly:
|
||||||
|
@ -3,19 +3,21 @@ import 'package:flutter/cupertino.dart';
|
|||||||
class PageRoutes {
|
class PageRoutes {
|
||||||
static const Duration kDefaultDuration = Duration(milliseconds: 300);
|
static const Duration kDefaultDuration = Duration(milliseconds: 300);
|
||||||
|
|
||||||
static Route<T> dialog<T>(Widget child, [Duration duration = kDefaultDuration, bool opaque = false]) {
|
static Route<T> dialog<T>(Widget child, {Duration duration = kDefaultDuration, bool opaque = false}) {
|
||||||
// Use cupertino routes for all dialogs so we get the 'swipe right to go back' behavior
|
// Use cupertino routes for all dialogs so we get the 'swipe right to go back' behavior
|
||||||
|
if (opaque) {
|
||||||
return CupertinoPageRoute(builder: (_) => child);
|
return CupertinoPageRoute(builder: (_) => child);
|
||||||
|
}
|
||||||
|
|
||||||
// SB: Removed this in favor of Cupertino routes, we could restore with a `useFade` option
|
// SB: Removed this in favor of Cupertino routes, we could restore with a `useFade` option
|
||||||
// return PageRouteBuilder<T>(
|
return PageRouteBuilder<T>(
|
||||||
// transitionDuration: duration,
|
transitionDuration: duration,
|
||||||
// reverseTransitionDuration: duration,
|
reverseTransitionDuration: duration,
|
||||||
// pageBuilder: (context, animation, secondaryAnimation) => child,
|
pageBuilder: (context, animation, secondaryAnimation) => child,
|
||||||
// opaque: opaque,
|
opaque: opaque,
|
||||||
// fullscreenDialog: true,
|
fullscreenDialog: true,
|
||||||
// transitionsBuilder: (context, animation, secondaryAnimation, child) =>
|
transitionsBuilder: (context, animation, secondaryAnimation, child) =>
|
||||||
// FadeTransition(opacity: animation, child: child),
|
FadeTransition(opacity: animation, child: child),
|
||||||
// );
|
);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -62,6 +62,7 @@ class _HomeScreenState extends State<HomeScreen> with SingleTickerProviderStateM
|
|||||||
WonderType? pickedWonder = await appLogic.showFullscreenDialogRoute<WonderType>(
|
WonderType? pickedWonder = await appLogic.showFullscreenDialogRoute<WonderType>(
|
||||||
context,
|
context,
|
||||||
HomeMenu(data: currentWonder),
|
HomeMenu(data: currentWonder),
|
||||||
|
transparent: true,
|
||||||
);
|
);
|
||||||
setState(() => _isMenuOpen = false);
|
setState(() => _isMenuOpen = false);
|
||||||
if (pickedWonder != null) {
|
if (pickedWonder != null) {
|
||||||
|
@ -4,7 +4,11 @@ class WonderDetailsTabMenu extends StatelessWidget {
|
|||||||
static double bottomPadding = 0;
|
static double bottomPadding = 0;
|
||||||
static double buttonInset = 12;
|
static double buttonInset = 12;
|
||||||
|
|
||||||
const WonderDetailsTabMenu({Key? key, required this.tabController, this.showBg = false, required this.wonderType})
|
const WonderDetailsTabMenu(
|
||||||
|
{Key? key,
|
||||||
|
required this.tabController,
|
||||||
|
this.showBg = false,
|
||||||
|
required this.wonderType})
|
||||||
: super(key: key);
|
: super(key: key);
|
||||||
|
|
||||||
final TabController tabController;
|
final TabController tabController;
|
||||||
@ -32,7 +36,10 @@ class WonderDetailsTabMenu extends StatelessWidget {
|
|||||||
),
|
),
|
||||||
// Buttons
|
// Buttons
|
||||||
Padding(
|
Padding(
|
||||||
padding: EdgeInsets.only(left: $styles.insets.sm, right: $styles.insets.xxs, bottom: bottomPadding),
|
padding: EdgeInsets.only(
|
||||||
|
left: $styles.insets.sm,
|
||||||
|
right: $styles.insets.xxs,
|
||||||
|
bottom: bottomPadding),
|
||||||
// TabButtons are a Stack with a row of icon buttons, and an illustrated home button sitting on top.
|
// TabButtons are a Stack with a row of icon buttons, and an illustrated home button sitting on top.
|
||||||
// The home buttons shows / hides itself based on `showHomeBtn`
|
// The home buttons shows / hides itself based on `showHomeBtn`
|
||||||
// The row contains an animated placeholder gap which makes room for the icon as it transitions in.
|
// The row contains an animated placeholder gap which makes room for the icon as it transitions in.
|
||||||
@ -52,13 +59,21 @@ class WonderDetailsTabMenu extends StatelessWidget {
|
|||||||
borderSize: showBg ? 6 : 2,
|
borderSize: showBg ? 6 : 2,
|
||||||
),
|
),
|
||||||
_TabBtn(0, tabController,
|
_TabBtn(0, tabController,
|
||||||
iconImg: 'editorial', label: $strings.wonderDetailsTabLabelInformation, color: iconColor),
|
iconImg: 'editorial',
|
||||||
|
label: $strings.wonderDetailsTabLabelInformation,
|
||||||
|
color: iconColor),
|
||||||
_TabBtn(1, tabController,
|
_TabBtn(1, tabController,
|
||||||
iconImg: 'photos', label: $strings.wonderDetailsTabLabelImages, color: iconColor),
|
iconImg: 'photos',
|
||||||
|
label: $strings.wonderDetailsTabLabelImages,
|
||||||
|
color: iconColor),
|
||||||
_TabBtn(2, tabController,
|
_TabBtn(2, tabController,
|
||||||
iconImg: 'artifacts', label: $strings.wonderDetailsTabLabelArtifacts, color: iconColor),
|
iconImg: 'artifacts',
|
||||||
|
label: $strings.wonderDetailsTabLabelArtifacts,
|
||||||
|
color: iconColor),
|
||||||
_TabBtn(3, tabController,
|
_TabBtn(3, tabController,
|
||||||
iconImg: 'timeline', label: $strings.wonderDetailsTabLabelEvents, color: iconColor),
|
iconImg: 'timeline',
|
||||||
|
label: $strings.wonderDetailsTabLabelEvents,
|
||||||
|
color: iconColor),
|
||||||
],
|
],
|
||||||
),
|
),
|
||||||
),
|
),
|
||||||
@ -72,7 +87,11 @@ class WonderDetailsTabMenu extends StatelessWidget {
|
|||||||
}
|
}
|
||||||
|
|
||||||
class _WonderHomeBtn extends StatelessWidget {
|
class _WonderHomeBtn extends StatelessWidget {
|
||||||
const _WonderHomeBtn({Key? key, required this.size, required this.wonderType, required this.borderSize})
|
const _WonderHomeBtn(
|
||||||
|
{Key? key,
|
||||||
|
required this.size,
|
||||||
|
required this.wonderType,
|
||||||
|
required this.borderSize})
|
||||||
: super(key: key);
|
: super(key: key);
|
||||||
|
|
||||||
final double size;
|
final double size;
|
||||||
@ -94,7 +113,8 @@ class _WonderHomeBtn extends StatelessWidget {
|
|||||||
decoration: BoxDecoration(
|
decoration: BoxDecoration(
|
||||||
borderRadius: BorderRadius.circular(99),
|
borderRadius: BorderRadius.circular(99),
|
||||||
color: wonderType.fgColor,
|
color: wonderType.fgColor,
|
||||||
image: DecorationImage(image: AssetImage(wonderType.homeBtn), fit: BoxFit.fill),
|
image: DecorationImage(
|
||||||
|
image: AssetImage(wonderType.homeBtn), fit: BoxFit.fill),
|
||||||
),
|
),
|
||||||
),
|
),
|
||||||
);
|
);
|
||||||
@ -111,6 +131,9 @@ class _TabBtn extends StatelessWidget {
|
|||||||
required this.label,
|
required this.label,
|
||||||
}) : super(key: key);
|
}) : super(key: key);
|
||||||
|
|
||||||
|
static const double _minWidth = 50;
|
||||||
|
static const double _maxWidth = 120;
|
||||||
|
|
||||||
final int index;
|
final int index;
|
||||||
final TabController tabController;
|
final TabController tabController;
|
||||||
final String iconImg;
|
final String iconImg;
|
||||||
@ -120,23 +143,29 @@ class _TabBtn extends StatelessWidget {
|
|||||||
@override
|
@override
|
||||||
Widget build(BuildContext context) {
|
Widget build(BuildContext context) {
|
||||||
bool selected = tabController.index == index;
|
bool selected = tabController.index == index;
|
||||||
final MaterialLocalizations localizations = MaterialLocalizations.of(context);
|
final MaterialLocalizations localizations =
|
||||||
final iconImgPath = '${ImagePaths.common}/tab-$iconImg${selected ? '-active' : ''}.png';
|
MaterialLocalizations.of(context);
|
||||||
String tabLabel = localizations.tabLabel(tabIndex: index + 1, tabCount: tabController.length);
|
final iconImgPath =
|
||||||
|
'${ImagePaths.common}/tab-$iconImg${selected ? '-active' : ''}.png';
|
||||||
|
String tabLabel = localizations.tabLabel(
|
||||||
|
tabIndex: index + 1, tabCount: tabController.length);
|
||||||
tabLabel = '$label: $tabLabel';
|
tabLabel = '$label: $tabLabel';
|
||||||
final double btnWidth = (context.widthPx / 6).clamp(50, 120);
|
final double btnWidth = (context.widthPx / 6).clamp(_minWidth, _maxWidth);
|
||||||
return MergeSemantics(
|
return MergeSemantics(
|
||||||
child: Semantics(
|
child: Semantics(
|
||||||
selected: selected,
|
selected: selected,
|
||||||
label: tabLabel,
|
label: tabLabel,
|
||||||
child: ExcludeSemantics(
|
child: ExcludeSemantics(
|
||||||
child: AppBtn.basic(
|
child: AppBtn.basic(
|
||||||
padding: EdgeInsets.only(top: $styles.insets.md + $styles.insets.xs, bottom: $styles.insets.sm),
|
padding: EdgeInsets.only(
|
||||||
|
top: $styles.insets.md + $styles.insets.xs,
|
||||||
|
bottom: $styles.insets.sm),
|
||||||
onPressed: () => tabController.index = index,
|
onPressed: () => tabController.index = index,
|
||||||
semanticLabel: label,
|
semanticLabel: label,
|
||||||
minimumSize: Size(btnWidth, 0),
|
minimumSize: Size(btnWidth, 0),
|
||||||
// Image icon
|
// Image icon
|
||||||
child: Image.asset(iconImgPath, height: 32, width: 32, color: selected ? null : color),
|
child: Image.asset(iconImgPath,
|
||||||
|
height: 32, width: 32, color: selected ? null : color),
|
||||||
),
|
),
|
||||||
),
|
),
|
||||||
),
|
),
|
||||||
|
Loading…
x
Reference in New Issue
Block a user