Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Landscape-Mode for RideView #335

Merged
merged 38 commits into from
Oct 27, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
38 commits
Select commit Hold shift + click to select a range
39ea8a0
Empty-Commit
kruegercharles Sep 29, 2023
9d63097
add ride_orientation enum
kruegercharles Oct 5, 2023
1e9d81a
remove ride orientation again, use operating system api
kruegercharles Oct 6, 2023
fc93454
first draft landscape mode
kruegercharles Oct 6, 2023
a862ce1
set map in landscape to the left
kruegercharles Oct 9, 2023
e347b59
Refactore RideView: use one build method instead of 2 render methods
kruegercharles Oct 9, 2023
c99a861
removed redundant renderLandscape method
kruegercharles Oct 9, 2023
995fde9
fix distortion when jumping to FeedbackView
kruegercharles Oct 9, 2023
3080d4f
wrap rideview in SafeArea
kruegercharles Oct 9, 2023
e9fc0bf
remove triangle speedometer landscapemode
kruegercharles Oct 9, 2023
fc0a9cf
move setting of landscapemode to ride view instead of speedometer
kruegercharles Oct 9, 2023
fa07298
remove unnecessary import
kruegercharles Oct 9, 2023
a28bf98
wrap DialogLayout in ScrollView
kruegercharles Oct 9, 2023
c91d7ff
set allowed device orientation in loader
kruegercharles Oct 9, 2023
e2c8ebc
implement first version of shadow for speedometer
kruegercharles Oct 9, 2023
ded9c26
remove weird space right of speedometer
kruegercharles Oct 11, 2023
0e7b60e
Fix: pressing on the speedometer now sets speed correctly
kruegercharles Oct 11, 2023
5db08bc
polishing
kruegercharles Oct 11, 2023
23baa36
fine tuning
kruegercharles Oct 11, 2023
f58804a
set end-button to the left
kruegercharles Oct 11, 2023
8969c22
make speedometer bigger and use pixelration for map offset
kruegercharles Oct 11, 2023
66a94e7
set mapbox logo position based on android or ios
kruegercharles Oct 11, 2023
d410e63
only use safe area for rideview in android
kruegercharles Oct 12, 2023
f0f8e2c
fix bug async dispose
kruegercharles Oct 12, 2023
d8852d3
fix position mapbox logo and button android & ios
kruegercharles Oct 13, 2023
8a99ffa
activate landscape mode in xcode
kruegercharles Oct 13, 2023
8416ec8
tweaking
kruegercharles Oct 13, 2023
9e2ccb4
remove async dispose
kruegercharles Oct 13, 2023
0c91a5b
disallow landscape mode in finishridebutton rather than dispose()
kruegercharles Oct 13, 2023
1e20869
final touch
kruegercharles Oct 13, 2023
9589d78
fix CI after rebase
kruegercharles Oct 19, 2023
3b801a1
center traffic light in landscape mode
kruegercharles Oct 20, 2023
c05a33f
remove portrait ride
kruegercharles Oct 20, 2023
c0c1d3c
readd portrait in ride view
kruegercharles Oct 20, 2023
68176cc
make end botton completely circular in landscape mode
kruegercharles Oct 20, 2023
7ab75ce
simplify position mapbox logo and button by using padding top
kruegercharles Oct 20, 2023
32a80d9
removed unused import
kruegercharles Oct 20, 2023
8404aeb
remove bottom safe area ride view for ios
kruegercharles Oct 27, 2023
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
159 changes: 80 additions & 79 deletions ios/Runner/Info.plist
Original file line number Diff line number Diff line change
@@ -1,83 +1,84 @@
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
<plist version="1.0">
<dict>
<key>CADisableMinimumFrameDurationOnPhone</key>
<true/>
<key>CFBundleDevelopmentRegion</key>
<string>$(DEVELOPMENT_LANGUAGE)</string>
<key>CFBundleExecutable</key>
<string>$(EXECUTABLE_NAME)</string>
<key>CFBundleIdentifier</key>
<string>$(PRODUCT_BUNDLE_IDENTIFIER)</string>
<key>CFBundleInfoDictionaryVersion</key>
<string>6.0</string>
<key>CFBundleName</key>
<string>PrioBike-HH</string>
<key>CFBundlePackageType</key>
<string>APPL</string>
<key>CFBundleShortVersionString</key>
<string>$(FLUTTER_BUILD_NAME)</string>
<key>CFBundleSignature</key>
<string>????</string>
<key>CFBundleVersion</key>
<string>$(FLUTTER_BUILD_NUMBER)</string>
<key>FirebaseAppDelegateProxyEnabled</key>
<false/>
<key>ITSAppUsesNonExemptEncryption</key>
<false/>
<key>LSApplicationCategoryType</key>
<string>public.app-category.navigation</string>
<key>LSRequiresIPhoneOS</key>
<true/>
<key>NSAllowArbitraryLoads</key>
<true/>
<key>NSLocationWhenInUseUsageDescription</key>
<string>Die App benötigt den Standort zur Navigation.</string>
<key>NSLocationAlwaysAndWhenInUseUsageDescription</key>
<string>Die App benötigt den Standort zur Navigation.</string>
<key>UIBackgroundModes</key>
<array>
<string>fetch</string>
<string>remote-notification</string>
</array>
<key>UILaunchStoryboardName</key>
<string>LaunchScreen</string>
<key>UIMainStoryboardFile</key>
<string>Main</string>
<key>UIStatusBarHidden</key>
<false/>
<key>UIStatusBarStyle</key>
<string>UIStatusBarStyleDefault</string>
<key>UISupportedInterfaceOrientations</key>
<array>
<string>UIInterfaceOrientationPortrait</string>
</array>
<key>UISupportedInterfaceOrientations~ipad</key>
<array>
<string>UIInterfaceOrientationPortrait</string>
<string>UIInterfaceOrientationPortraitUpsideDown</string>
<string>UIInterfaceOrientationLandscapeLeft</string>
<string>UIInterfaceOrientationLandscapeRight</string>
</array>
<key>UIViewControllerBasedStatusBarAppearance</key>
<false/>
<key>NSLocalNetworkUsageDescription</key>
<string>Diese App nutzt TCP-Netzwerkdienste, um Verbindungen zu Ampeln herzustellen, und braucht hierfür Deine Erlaubnis.</string>
<key>NSBonjourServices</key>
<array>
<string>mqtt.tcp</string>
</array>
<key>UIApplicationSupportsIndirectInputEvents</key>
<true/>
<key>FIREBASE_ANALYTICS_COLLECTION_DEACTIVATED</key>
<true/>
<key>NSCameraUsageDescription</key>
<string>Diese App nutzt die Kamera, um QR-Codes zu scannen.</string>
<key>LSApplicationQueriesSchemes</key>
<array>
<string>https</string>
<string>mailto</string>
</array>
</dict>
<dict>
<key>CADisableMinimumFrameDurationOnPhone</key>
<true/>
<key>CFBundleDevelopmentRegion</key>
<string>$(DEVELOPMENT_LANGUAGE)</string>
<key>CFBundleExecutable</key>
<string>$(EXECUTABLE_NAME)</string>
<key>CFBundleIdentifier</key>
<string>$(PRODUCT_BUNDLE_IDENTIFIER)</string>
<key>CFBundleInfoDictionaryVersion</key>
<string>6.0</string>
<key>CFBundleName</key>
<string>PrioBike-HH</string>
<key>CFBundlePackageType</key>
<string>APPL</string>
<key>CFBundleShortVersionString</key>
<string>$(FLUTTER_BUILD_NAME)</string>
<key>CFBundleSignature</key>
<string>????</string>
<key>CFBundleVersion</key>
<string>$(FLUTTER_BUILD_NUMBER)</string>
<key>FIREBASE_ANALYTICS_COLLECTION_DEACTIVATED</key>
<true/>
<key>FirebaseAppDelegateProxyEnabled</key>
<false/>
<key>ITSAppUsesNonExemptEncryption</key>
<false/>
<key>LSApplicationCategoryType</key>
<string>public.app-category.navigation</string>
<key>LSApplicationQueriesSchemes</key>
<array>
<string>https</string>
<string>mailto</string>
</array>
<key>LSRequiresIPhoneOS</key>
<true/>
<key>NSAllowArbitraryLoads</key>
<true/>
<key>NSBonjourServices</key>
<array>
<string>mqtt.tcp</string>
</array>
<key>NSCameraUsageDescription</key>
<string>Diese App nutzt die Kamera, um QR-Codes zu scannen.</string>
<key>NSLocalNetworkUsageDescription</key>
<string>Diese App nutzt TCP-Netzwerkdienste, um Verbindungen zu Ampeln herzustellen, und braucht hierfür deine Erlaubnis.</string>
<key>NSLocationAlwaysAndWhenInUseUsageDescription</key>
<string>Die App benötigt den Standort zur Navigation.</string>
<key>NSLocationWhenInUseUsageDescription</key>
<string>Die App benötigt den Standort zur Navigation.</string>
<key>UIApplicationSupportsIndirectInputEvents</key>
<true/>
<key>UIBackgroundModes</key>
<array>
<string>fetch</string>
<string>remote-notification</string>
</array>
<key>UILaunchStoryboardName</key>
<string>LaunchScreen</string>
<key>UIMainStoryboardFile</key>
<string>Main</string>
<key>UIStatusBarHidden</key>
<false/>
<key>UIStatusBarStyle</key>
<string>UIStatusBarStyleDefault</string>
<key>UISupportedInterfaceOrientations</key>
<array>
<string>UIInterfaceOrientationLandscapeLeft</string>
<string>UIInterfaceOrientationLandscapeRight</string>
<string>UIInterfaceOrientationPortrait</string>
</array>
<key>UISupportedInterfaceOrientations~ipad</key>
<array>
<string>UIInterfaceOrientationLandscapeLeft</string>
<string>UIInterfaceOrientationLandscapeRight</string>
<string>UIInterfaceOrientationPortrait</string>
</array>
<key>UIViewControllerBasedStatusBarAppearance</key>
<false/>
</dict>
</plist>
58 changes: 32 additions & 26 deletions lib/common/layout/dialog.dart
Original file line number Diff line number Diff line change
Expand Up @@ -208,6 +208,8 @@ class DialogLayoutState extends State<DialogLayout> with WidgetsBindingObserver
// Initial state of the bottom padding.
paddingBottom = MediaQuery.of(context).viewInsets.bottom;

final orientation = MediaQuery.of(context).orientation;

return AnimatedPadding(
padding: EdgeInsets.only(bottom: paddingBottom),
duration: const Duration(milliseconds: 200),
Expand All @@ -220,39 +222,43 @@ class DialogLayoutState extends State<DialogLayout> with WidgetsBindingObserver
child: Material(
color: Colors.transparent,
child: Container(
width: MediaQuery.of(context).size.width * 0.8,
width: orientation == Orientation.portrait
? MediaQuery.of(context).size.width * 0.8
: MediaQuery.of(context).size.width * 0.6,
padding: const EdgeInsets.symmetric(horizontal: 16, vertical: 16),
decoration: BoxDecoration(
borderRadius: const BorderRadius.all(Radius.circular(24)),
color: Theme.of(context).colorScheme.background.withOpacity(0.6),
),
child: Column(
mainAxisSize: MainAxisSize.min,
mainAxisAlignment: MainAxisAlignment.center,
children: [
if (widget.icon != null)
Icon(
widget.icon!,
color: widget.iconColor ?? Theme.of(context).colorScheme.primary,
size: 36,
child: SingleChildScrollView(
child: Column(
mainAxisSize: MainAxisSize.min,
mainAxisAlignment: MainAxisAlignment.center,
children: [
if (widget.icon != null)
Icon(
widget.icon!,
color: widget.iconColor ?? Theme.of(context).colorScheme.primary,
size: 36,
),
if (widget.icon != null) const SmallVSpace(),
BoldSubHeader(
context: context,
text: widget.title,
textAlign: TextAlign.center,
),
if (widget.icon != null) const SmallVSpace(),
BoldSubHeader(
context: context,
text: widget.title,
textAlign: TextAlign.center,
),
const SmallVSpace(),
Content(
context: context,
text: widget.text,
textAlign: TextAlign.center,
),
if (widget.actions != null) ...[
const SmallVSpace(),
...actions,
]
],
Content(
context: context,
text: widget.text,
textAlign: TextAlign.center,
),
if (widget.actions != null) ...[
const SmallVSpace(),
...actions,
]
],
),
),
),
),
Expand Down
5 changes: 5 additions & 0 deletions lib/loader.dart
Original file line number Diff line number Diff line change
Expand Up @@ -94,6 +94,11 @@ class LoaderState extends State<Loader> {
await MapboxTileImageCache.pruneUnusedImages();
getIt<EvaluationDataService>().sendUnsentElements();

// Only allow portrait mode.
await SystemChrome.setPreferredOrientations([
DeviceOrientation.portraitUp,
]);

settings.incrementUseCounter();
} catch (e, stacktrace) {
log.e("Error while loading services $e\n $stacktrace");
Expand Down
26 changes: 18 additions & 8 deletions lib/ride/views/finish_button.dart
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
import 'package:flutter/material.dart';
import 'package:flutter/services.dart';
import 'package:priobike/common/layout/buttons.dart';
import 'package:priobike/common/layout/dialog.dart';
import 'package:priobike/common/layout/spacing.dart';
Expand Down Expand Up @@ -62,6 +63,11 @@ class FinishRideButtonState extends State<FinishRideButton> {

/// A callback that is executed when the cancel button is pressed.
Future<void> onTap() async {
// Allows only portrait mode again when leaving the ride view.
await SystemChrome.setPreferredOrientations([
DeviceOrientation.portraitUp,
]);

// End the tracking and collect the data.
final tracking = getIt<Tracking>();
await tracking.end(); // Performs all needed resets.
Expand All @@ -87,11 +93,8 @@ class FinishRideButtonState extends State<FinishRideButton> {
final position = getIt<Positioning>();
await position.stopGeolocation();

// Show the feedback dialog.
// Show the feedback view.
if (mounted) {
// Pop everything until ride view is reached and then replace it with the feedback view.
// Otherwise the ride view stays in the widget tree and is shown for a split seconds after closing the feedback view.

Navigator.of(context).pushAndRemoveUntil(
MaterialPageRoute<void>(
builder: (BuildContext context) => FeedbackView(
Expand Down Expand Up @@ -129,17 +132,24 @@ class FinishRideButtonState extends State<FinishRideButton> {

@override
Widget build(BuildContext context) {
final orientation = MediaQuery.of(context).orientation;
final isLandscapeMode = orientation == Orientation.landscape;

return Stack(
children: [
Positioned(
top: 48, // Below the MapBox attribution.
right: 0,
// Button is on the right in portrait mode and on the left in landscape mode.
right: isLandscapeMode ? null : 0,
left: isLandscapeMode ? 0 : null,
child: SafeArea(
child: Tile(
onPressed: () => showAskForConfirmationDialog(context),
borderRadius: const BorderRadius.only(
topLeft: Radius.circular(24),
bottomLeft: Radius.circular(24),
borderRadius: BorderRadius.only(
topLeft: const Radius.circular(24),
bottomLeft: const Radius.circular(24),
topRight: isLandscapeMode ? const Radius.circular(24) : const Radius.circular(0),
bottomRight: isLandscapeMode ? const Radius.circular(24) : const Radius.circular(0),
),
padding: const EdgeInsets.all(4),
fill: Colors.black.withOpacity(0.4),
Expand Down
Loading
Loading