2
0
mirror of https://github.com/inventree/inventree-app.git synced 2025-06-12 18:25:26 +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

@ -10,6 +10,51 @@ import "package:inventree/preferences.dart";
import "package:inventree/widget/snacks.dart";
/*
* Launch a dialog allowing the user to select from a list of options
*/
Future<void> choiceDialog(String title, List<Widget> items, {Function? onSelected}) async {
List<Widget> choices = [];
for (int idx = 0; idx < items.length; idx++) {
choices.add(
GestureDetector(
child: items[idx],
onTap: () {
Navigator.pop(OneContext().context!);
if (onSelected != null) {
onSelected(idx);
}
},
)
);
}
OneContext().showDialog(
builder: (BuildContext context) {
return AlertDialog(
title: Text(title),
content: SingleChildScrollView(
child: Column(
children: choices,
)
),
actions: [
TextButton(
child: Text(L10().cancel),
onPressed: () {
Navigator.pop(OneContext().context!);
},
)
],
);
}
);
}
/*
* Display a "confirmation" dialog allowing the user to accept or reject an action
*/