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:
@ -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
|
||||
*/
|
||||
|
Reference in New Issue
Block a user