2
0
mirror of https://github.com/inventree/inventree-app.git synced 2025-06-12 02:05:29 +00:00

App orientation (#369)

* Configurable screen orientation

- Follow system (default)
- Fixed in portrait
- Fixed in landscape

* Fix for dialog
This commit is contained in:
Oliver
2023-06-13 19:53:50 +10:00
committed by GitHub
parent ba409660f4
commit 71bf3ad049
6 changed files with 185 additions and 40 deletions

View File

@ -55,9 +55,29 @@ Future<void> main() async {
);
};
runApp(
InvenTreeApp(savedThemeMode)
);
final int orientation = await InvenTreeSettingsManager().getValue(INV_SCREEN_ORIENTATION, SCREEN_ORIENTATION_SYSTEM) as int;
List<DeviceOrientation> orientations = [];
switch (orientation) {
case SCREEN_ORIENTATION_PORTRAIT:
orientations.add(DeviceOrientation.portraitUp);
break;
case SCREEN_ORIENTATION_LANDSCAPE:
orientations.add(DeviceOrientation.landscapeLeft);
break;
default:
orientations.add(DeviceOrientation.portraitUp);
orientations.add(DeviceOrientation.landscapeLeft);
orientations.add(DeviceOrientation.landscapeRight);
break;
}
SystemChrome.setPreferredOrientations(orientations).then((_) {
runApp(
InvenTreeApp(savedThemeMode)
);
});
}, (Object error, StackTrace stackTrace) async {
sentryReportError("main.runZonedGuarded", error, stackTrace);