Formatted some files
This commit is contained in:
parent
5cd21c8adf
commit
89c0b069e1
4 changed files with 27 additions and 18 deletions
|
@ -12,9 +12,9 @@ import 'dart:math';
|
||||||
class EditCategoryPage extends StatefulWidget {
|
class EditCategoryPage extends StatefulWidget {
|
||||||
final String server;
|
final String server;
|
||||||
final String tag;
|
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
|
@override
|
||||||
State<StatefulWidget> createState() => _EditCategoryPageState();
|
State<StatefulWidget> createState() => _EditCategoryPageState();
|
||||||
|
@ -30,7 +30,13 @@ class _EditCategoryPageState extends State<EditCategoryPage> {
|
||||||
void initState() {
|
void initState() {
|
||||||
super.initState();
|
super.initState();
|
||||||
|
|
||||||
WidgetsBinding.instance.addPostFrameCallback((_) => fetchCategory());
|
WidgetsBinding.instance.addPostFrameCallback((_) {
|
||||||
|
if (widget.id == null) {
|
||||||
|
// trying to create a new category
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
fetchCategory();
|
||||||
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
void fetchCategory() {
|
void fetchCategory() {
|
||||||
|
@ -46,7 +52,8 @@ class _EditCategoryPageState extends State<EditCategoryPage> {
|
||||||
body: {
|
body: {
|
||||||
'room': widget.tag,
|
'room': widget.tag,
|
||||||
'server': widget.server,
|
'server': widget.server,
|
||||||
'listCatID': widget.id}),
|
'listCatID': widget.id
|
||||||
|
}),
|
||||||
onOK: (json) {
|
onOK: (json) {
|
||||||
setState(() {
|
setState(() {
|
||||||
_ctrName.text = json['data']['title'];
|
_ctrName.text = json['data']['title'];
|
||||||
|
@ -241,8 +248,7 @@ class _EditCategoryPageState extends State<EditCategoryPage> {
|
||||||
label: Text((widget.id == null)
|
label: Text((widget.id == null)
|
||||||
? AppLocalizations.of(context)!.newCategoryShort
|
? AppLocalizations.of(context)!.newCategoryShort
|
||||||
: AppLocalizations.of(context)!.editCategoryShort),
|
: AppLocalizations.of(context)!.editCategoryShort),
|
||||||
icon: Icon((widget.id == null)
|
icon: Icon((widget.id == null) ? Icons.add : Icons.edit)),
|
||||||
? Icons.add : Icons.edit)),
|
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -76,6 +76,11 @@ class _RoomPageState extends State<RoomPage> {
|
||||||
void initState() {
|
void initState() {
|
||||||
super.initState();
|
super.initState();
|
||||||
|
|
||||||
|
room = Room(
|
||||||
|
id: widget.tag,
|
||||||
|
serverTag: widget.server
|
||||||
|
);
|
||||||
|
|
||||||
_ctr.addListener(() {
|
_ctr.addListener(() {
|
||||||
setState(() {
|
setState(() {
|
||||||
page = _ctr.page?.toInt() ?? _ctr.initialPage;
|
page = _ctr.page?.toInt() ?? _ctr.initialPage;
|
||||||
|
@ -126,23 +131,19 @@ class _RoomPageState extends State<RoomPage> {
|
||||||
NavigationDestination(
|
NavigationDestination(
|
||||||
icon: const Icon(Icons.list),
|
icon: const Icon(Icons.list),
|
||||||
label: AppLocalizations.of(context)!.roomListTitle,
|
label: AppLocalizations.of(context)!.roomListTitle,
|
||||||
tooltip: AppLocalizations.of(context)!.roomListSubtitle
|
tooltip: AppLocalizations.of(context)!.roomListSubtitle),
|
||||||
),
|
|
||||||
NavigationDestination(
|
NavigationDestination(
|
||||||
icon: const Icon(Icons.inventory_2),
|
icon: const Icon(Icons.inventory_2),
|
||||||
label: AppLocalizations.of(context)!.roomProductsTitle,
|
label: AppLocalizations.of(context)!.roomProductsTitle,
|
||||||
tooltip: AppLocalizations.of(context)!.roomProductsSubtitle
|
tooltip: AppLocalizations.of(context)!.roomProductsSubtitle),
|
||||||
),
|
|
||||||
NavigationDestination(
|
NavigationDestination(
|
||||||
icon: const Icon(Icons.category),
|
icon: const Icon(Icons.category),
|
||||||
label: AppLocalizations.of(context)!.roomCategoriesTitle,
|
label: AppLocalizations.of(context)!.roomCategoriesTitle,
|
||||||
tooltip: AppLocalizations.of(context)!.roomCategoriesSubtitle
|
tooltip: AppLocalizations.of(context)!.roomCategoriesSubtitle),
|
||||||
),
|
|
||||||
NavigationDestination(
|
NavigationDestination(
|
||||||
icon: const Icon(Icons.info_rounded),
|
icon: const Icon(Icons.info_rounded),
|
||||||
label: AppLocalizations.of(context)!.roomAboutTitle,
|
label: AppLocalizations.of(context)!.roomAboutTitle,
|
||||||
tooltip: AppLocalizations.of(context)!.roomAboutSubtitle
|
tooltip: AppLocalizations.of(context)!.roomAboutSubtitle),
|
||||||
),
|
|
||||||
],
|
],
|
||||||
),
|
),
|
||||||
);
|
);
|
||||||
|
|
|
@ -123,7 +123,7 @@ class _RoomCategoriesPageState extends State<RoomCategoriesPage> {
|
||||||
context.pushNamed('edit-category', params: {
|
context.pushNamed('edit-category', params: {
|
||||||
'server': widget.room!.serverTag,
|
'server': widget.room!.serverTag,
|
||||||
'id': widget.room!.id,
|
'id': widget.room!.id,
|
||||||
'cid': item.id.toString()
|
'category': item.id.toString()
|
||||||
});
|
});
|
||||||
},
|
},
|
||||||
),
|
),
|
||||||
|
|
|
@ -5,14 +5,15 @@ import 'package:outbag_app/tools/snackbar.dart';
|
||||||
import 'package:flutter_gen/gen_l10n/app_localizations.dart';
|
import 'package:flutter_gen/gen_l10n/app_localizations.dart';
|
||||||
|
|
||||||
Future<void> doNetworkRequest(ScaffoldMessengerState? sm,
|
Future<void> doNetworkRequest(ScaffoldMessengerState? sm,
|
||||||
{required Future<Response> Function() req,
|
{required Future<Response> Function() req,
|
||||||
Function(Map<String, dynamic> body)? onOK,
|
Function(Map<String, dynamic> body)? onOK,
|
||||||
bool Function()? onNetworkErr,
|
bool Function()? onNetworkErr,
|
||||||
bool Function()? onUnknownErr,
|
bool Function()? onUnknownErr,
|
||||||
Function()? onAnyErr,
|
Function()? onAnyErr,
|
||||||
Function()? after,
|
Function()? after,
|
||||||
bool Function(Map<String, dynamic>)? onServerErr}) async {
|
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;
|
Response res;
|
||||||
try {
|
try {
|
||||||
|
@ -50,7 +51,8 @@ Future<void> doNetworkRequest(ScaffoldMessengerState? sm,
|
||||||
showBar = onServerErr(res.body);
|
showBar = onServerErr(res.body);
|
||||||
}
|
}
|
||||||
if (showBar && sm != null) {
|
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) {
|
if (onAnyErr != null) {
|
||||||
onAnyErr();
|
onAnyErr();
|
||||||
|
|
Loading…
Reference in a new issue