Formatted some files

This commit is contained in:
Jakob Meier 2023-04-04 20:33:49 +02:00
parent 5cd21c8adf
commit 89c0b069e1
No known key found for this signature in database
GPG key ID: 66BDC7E6A01A6152
4 changed files with 27 additions and 18 deletions

View file

@ -12,9 +12,9 @@ import 'dart:math';
class EditCategoryPage extends StatefulWidget {
final String server;
final String tag;
int? id;
final int? id;
EditCategoryPage(this.server, this.tag, {super.key, this.id});
const EditCategoryPage(this.server, this.tag, {super.key, this.id});
@override
State<StatefulWidget> createState() => _EditCategoryPageState();
@ -30,7 +30,13 @@ class _EditCategoryPageState extends State<EditCategoryPage> {
void initState() {
super.initState();
WidgetsBinding.instance.addPostFrameCallback((_) => fetchCategory());
WidgetsBinding.instance.addPostFrameCallback((_) {
if (widget.id == null) {
// trying to create a new category
return;
}
fetchCategory();
});
}
void fetchCategory() {
@ -46,7 +52,8 @@ class _EditCategoryPageState extends State<EditCategoryPage> {
body: {
'room': widget.tag,
'server': widget.server,
'listCatID': widget.id}),
'listCatID': widget.id
}),
onOK: (json) {
setState(() {
_ctrName.text = json['data']['title'];
@ -241,8 +248,7 @@ class _EditCategoryPageState extends State<EditCategoryPage> {
label: Text((widget.id == null)
? AppLocalizations.of(context)!.newCategoryShort
: AppLocalizations.of(context)!.editCategoryShort),
icon: Icon((widget.id == null)
? Icons.add : Icons.edit)),
icon: Icon((widget.id == null) ? Icons.add : Icons.edit)),
);
}
}

View file

@ -76,6 +76,11 @@ class _RoomPageState extends State<RoomPage> {
void initState() {
super.initState();
room = Room(
id: widget.tag,
serverTag: widget.server
);
_ctr.addListener(() {
setState(() {
page = _ctr.page?.toInt() ?? _ctr.initialPage;
@ -126,23 +131,19 @@ class _RoomPageState extends State<RoomPage> {
NavigationDestination(
icon: const Icon(Icons.list),
label: AppLocalizations.of(context)!.roomListTitle,
tooltip: AppLocalizations.of(context)!.roomListSubtitle
),
tooltip: AppLocalizations.of(context)!.roomListSubtitle),
NavigationDestination(
icon: const Icon(Icons.inventory_2),
label: AppLocalizations.of(context)!.roomProductsTitle,
tooltip: AppLocalizations.of(context)!.roomProductsSubtitle
),
tooltip: AppLocalizations.of(context)!.roomProductsSubtitle),
NavigationDestination(
icon: const Icon(Icons.category),
label: AppLocalizations.of(context)!.roomCategoriesTitle,
tooltip: AppLocalizations.of(context)!.roomCategoriesSubtitle
),
tooltip: AppLocalizations.of(context)!.roomCategoriesSubtitle),
NavigationDestination(
icon: const Icon(Icons.info_rounded),
label: AppLocalizations.of(context)!.roomAboutTitle,
tooltip: AppLocalizations.of(context)!.roomAboutSubtitle
),
tooltip: AppLocalizations.of(context)!.roomAboutSubtitle),
],
),
);

View file

@ -123,7 +123,7 @@ class _RoomCategoriesPageState extends State<RoomCategoriesPage> {
context.pushNamed('edit-category', params: {
'server': widget.room!.serverTag,
'id': widget.room!.id,
'cid': item.id.toString()
'category': item.id.toString()
});
},
),

View file

@ -12,7 +12,8 @@ Future<void> doNetworkRequest(ScaffoldMessengerState? sm,
Function()? onAnyErr,
Function()? after,
bool Function(Map<String, dynamic>)? onServerErr}) async {
AppLocalizations? trans = (sm!=null)?AppLocalizations.of(sm.context):null;
AppLocalizations? trans =
(sm != null) ? AppLocalizations.of(sm.context) : null;
Response res;
try {
@ -50,7 +51,8 @@ Future<void> doNetworkRequest(ScaffoldMessengerState? sm,
showBar = onServerErr(res.body);
}
if (showBar && sm != null) {
showSimpleSnackbar(sm, text: errorAsString(res.body, trans!), action: trans.ok);
showSimpleSnackbar(sm,
text: errorAsString(res.body, trans!), action: trans.ok);
}
if (onAnyErr != null) {
onAnyErr();