Moved room pages into seperate folder
This commit is contained in:
parent
8e02de97c1
commit
eabb6b93ae
6 changed files with 369 additions and 361 deletions
|
@ -1,357 +0,0 @@
|
|||
import 'package:flutter/material.dart';
|
||||
import 'package:flutter_svg/flutter_svg.dart';
|
||||
import 'package:outbag_app/backend/errors.dart';
|
||||
import 'package:outbag_app/backend/permissions.dart';
|
||||
import 'package:outbag_app/backend/request.dart';
|
||||
import 'package:outbag_app/backend/room.dart';
|
||||
import 'dart:math';
|
||||
|
||||
import 'package:outbag_app/backend/user.dart';
|
||||
import 'package:routemaster/routemaster.dart';
|
||||
|
||||
class AboutRoomPage extends StatefulWidget {
|
||||
final RoomInfo? info;
|
||||
final Room? room;
|
||||
|
||||
const AboutRoomPage(this.room, this.info, {super.key});
|
||||
|
||||
@override
|
||||
State<StatefulWidget> createState() => _AboutRoomPageState();
|
||||
}
|
||||
|
||||
class _AboutRoomPageState extends State<AboutRoomPage> {
|
||||
@override
|
||||
void initState() {
|
||||
super.initState();
|
||||
}
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
final textTheme = Theme.of(context)
|
||||
.textTheme
|
||||
.apply(displayColor: Theme.of(context).colorScheme.onSurface);
|
||||
|
||||
double width = MediaQuery.of(context).size.width;
|
||||
double height = MediaQuery.of(context).size.height;
|
||||
double smallest = min(width, height);
|
||||
|
||||
return Center(
|
||||
child: Column(children: [
|
||||
// room meta display
|
||||
...(widget.room != null)
|
||||
? [
|
||||
Padding(
|
||||
padding: const EdgeInsets.all(14),
|
||||
child: Column(
|
||||
children: [
|
||||
SvgPicture.asset(
|
||||
(widget.room?.icon?.img)!,
|
||||
width: smallest * 0.2,
|
||||
height: smallest * 0.2,
|
||||
),
|
||||
Text(
|
||||
widget.room?.name ?? '',
|
||||
style: textTheme.displayMedium,
|
||||
),
|
||||
Text(
|
||||
'${widget.room?.id}@${widget.room?.serverTag}',
|
||||
style: textTheme.bodySmall,
|
||||
),
|
||||
Text(widget.room?.description ?? '',
|
||||
style: textTheme.bodyMedium),
|
||||
Padding(
|
||||
padding: const EdgeInsets.all(8),
|
||||
child: SegmentedButton<int>(
|
||||
showSelectedIcon: true,
|
||||
multiSelectionEnabled: false,
|
||||
emptySelectionAllowed: false,
|
||||
segments: RoomVisibility.list().map((vis) {
|
||||
return ButtonSegment<int>(
|
||||
value: vis.type,
|
||||
label: Text(vis.text),
|
||||
icon: Icon(vis.icon));
|
||||
}).toList(),
|
||||
onSelectionChanged: ((vset) {
|
||||
// check permission
|
||||
// only show confirm dialog when user
|
||||
// is admin, owner or has CHANGE_ADMIN permission
|
||||
if (widget.info == null ||
|
||||
(!(widget.info?.isAdmin ?? false) &&
|
||||
!(widget.info?.isOwner ?? false) &&
|
||||
((widget.info?.permissions)! &
|
||||
RoomPermission.ota ==
|
||||
0))) {
|
||||
// action not permitted
|
||||
// NOTE: no error dialog should be shown
|
||||
// because the action is supposed to be hidden
|
||||
return;
|
||||
}
|
||||
|
||||
final vis = RoomVisibility(vset.first);
|
||||
showDialog(
|
||||
context: context,
|
||||
builder: (ctx) => AlertDialog(
|
||||
title:
|
||||
const Text('Change room visibility'),
|
||||
content: Text(
|
||||
'Do you really want to change the room visibility to: ${vis.text}'),
|
||||
actions: [
|
||||
TextButton(
|
||||
onPressed: () {
|
||||
Navigator.of(context).pop();
|
||||
},
|
||||
child: const Text('Cancel'),
|
||||
),
|
||||
FilledButton(
|
||||
onPressed: () async {
|
||||
final scaffMgr =
|
||||
ScaffoldMessenger.of(context);
|
||||
final nav = Navigator.of(context);
|
||||
|
||||
User user;
|
||||
try {
|
||||
user = await User.fromDisk();
|
||||
} catch (_) {
|
||||
// probably not logged in
|
||||
nav.pop();
|
||||
return;
|
||||
}
|
||||
|
||||
try {
|
||||
final resp =
|
||||
await postWithCreadentials(
|
||||
path: 'setVisibility',
|
||||
target: user.server,
|
||||
body: {
|
||||
'room': widget.room?.id,
|
||||
'server': (widget
|
||||
.room?.serverTag)!,
|
||||
'visibility': vset.first
|
||||
},
|
||||
credentials: user);
|
||||
if (resp.res == Result.ok) {
|
||||
Room r = widget.room!;
|
||||
r.visibility = vis;
|
||||
r.toDisk();
|
||||
} else {
|
||||
// server error
|
||||
final snackBar = SnackBar(
|
||||
behavior:
|
||||
SnackBarBehavior.floating,
|
||||
content: Text(
|
||||
errorAsString(resp.body)),
|
||||
action: SnackBarAction(
|
||||
label: 'Dismiss',
|
||||
onPressed: () {
|
||||
scaffMgr
|
||||
.hideCurrentSnackBar();
|
||||
},
|
||||
),
|
||||
);
|
||||
|
||||
scaffMgr.hideCurrentSnackBar();
|
||||
scaffMgr.showSnackBar(snackBar);
|
||||
}
|
||||
} catch (_) {
|
||||
// network error
|
||||
final snackBar = SnackBar(
|
||||
behavior:
|
||||
SnackBarBehavior.floating,
|
||||
content:
|
||||
const Text('Network error'),
|
||||
action: SnackBarAction(
|
||||
label: 'Dismiss',
|
||||
onPressed: () {
|
||||
scaffMgr
|
||||
.hideCurrentSnackBar();
|
||||
},
|
||||
),
|
||||
);
|
||||
|
||||
scaffMgr.hideCurrentSnackBar();
|
||||
scaffMgr.showSnackBar(snackBar);
|
||||
}
|
||||
|
||||
nav.pop();
|
||||
},
|
||||
child: const Text('Ok'),
|
||||
)
|
||||
],
|
||||
));
|
||||
}),
|
||||
selected: {(widget.room?.visibility?.type)!},
|
||||
selectedIcon: Icon((widget.room?.visibility?.icon)!),
|
||||
)),
|
||||
],
|
||||
),
|
||||
)
|
||||
]
|
||||
: [],
|
||||
|
||||
Padding(
|
||||
padding: const EdgeInsets.all(14),
|
||||
child: Column(
|
||||
children: [
|
||||
// edit room meta button
|
||||
...(widget.info != null &&
|
||||
((widget.info?.isAdmin ?? false) ||
|
||||
(widget.info?.isOwner ?? false) ||
|
||||
((widget.info?.permissions)! &
|
||||
RoomPermission.changeMeta !=
|
||||
0)))
|
||||
? [
|
||||
ListTile(
|
||||
trailing: const Icon(Icons.chevron_right),
|
||||
title: const Text('Edit Metadata'),
|
||||
subtitle: const Text(
|
||||
'Change the rooms name, description and icon'),
|
||||
onTap: () {
|
||||
// show edit room screen
|
||||
Routemaster.of(context).push('/r/${widget.room?.serverTag}/${widget.room?.id}/edit');
|
||||
},
|
||||
),
|
||||
]
|
||||
: [],
|
||||
// open members view
|
||||
ListTile(
|
||||
trailing: const Icon(Icons.chevron_right),
|
||||
title: const Text('Members'),
|
||||
subtitle: const Text('Show Member list'),
|
||||
onTap: () {
|
||||
// open member view screen
|
||||
Routemaster.of(context).push('/r/${widget.room?.serverTag}/${widget.room?.id}/members');
|
||||
},
|
||||
),
|
||||
...(widget.info != null &&
|
||||
((widget.info?.isAdmin ?? false) ||
|
||||
(widget.info?.isOwner ?? false) ||
|
||||
((widget.info?.permissions)! & RoomPermission.ota !=
|
||||
0)))
|
||||
? [
|
||||
ListTile(
|
||||
trailing: const Icon(Icons.chevron_right),
|
||||
title: const Text('OTA'),
|
||||
subtitle: const Text('Manage and delete OTAs'),
|
||||
onTap: () {
|
||||
// show manage ota screen
|
||||
Routemaster.of(context).push('/r/${widget.room?.serverTag}/${widget.room?.id}/ota');
|
||||
},
|
||||
),
|
||||
]
|
||||
: [],
|
||||
],
|
||||
)),
|
||||
|
||||
...(widget.info != null)
|
||||
? [
|
||||
Padding(
|
||||
padding: const EdgeInsets.all(8),
|
||||
child: FilledButton.tonal(
|
||||
child: Text(((widget.info?.isOwner)!)
|
||||
? 'Delete Room'
|
||||
: 'Leave Room'),
|
||||
onPressed: () {
|
||||
// show confirm dialog
|
||||
showDialog(
|
||||
context: context,
|
||||
builder: (ctx) => AlertDialog(
|
||||
title: Text(((widget.info?.isOwner)!)
|
||||
? 'Delete Room'
|
||||
: 'Leave Room'),
|
||||
content: Text(
|
||||
'Do you really want to ${((widget.info?.isOwner)!) ? "delete" : "leave"} the room?'),
|
||||
actions: [
|
||||
TextButton(
|
||||
onPressed: () {
|
||||
// close popup
|
||||
Navigator.of(ctx).pop();
|
||||
},
|
||||
child: const Text('Cancel'),
|
||||
),
|
||||
FilledButton(
|
||||
onPressed: () async {
|
||||
// send request
|
||||
final scaffMgr =
|
||||
ScaffoldMessenger.of(ctx);
|
||||
final nav = Navigator.of(ctx);
|
||||
final rmaster = Routemaster.of(ctx);
|
||||
|
||||
User user;
|
||||
try {
|
||||
user = await User.fromDisk();
|
||||
} catch (_) {
|
||||
// probably not logged in
|
||||
nav.pop();
|
||||
return;
|
||||
}
|
||||
|
||||
try {
|
||||
final resp = await postWithCreadentials(
|
||||
path: ((widget.info?.isOwner)!)
|
||||
? 'deleteRoom'
|
||||
: 'leaveRoom',
|
||||
target: user.server,
|
||||
body: {
|
||||
'room': widget.room?.id,
|
||||
'server':
|
||||
(widget.room?.serverTag)!,
|
||||
},
|
||||
credentials: user);
|
||||
if (resp.res == Result.ok) {
|
||||
// try delete room from disk
|
||||
try {
|
||||
await widget.room?.removeDisk();
|
||||
} catch (_) {}
|
||||
|
||||
// go back home
|
||||
rmaster.replace('/');
|
||||
} else {
|
||||
// server error
|
||||
final snackBar = SnackBar(
|
||||
behavior: SnackBarBehavior.floating,
|
||||
content:
|
||||
Text(errorAsString(resp.body)),
|
||||
action: SnackBarAction(
|
||||
label: 'Dismiss',
|
||||
onPressed: () {
|
||||
scaffMgr.hideCurrentSnackBar();
|
||||
},
|
||||
),
|
||||
);
|
||||
|
||||
scaffMgr.hideCurrentSnackBar();
|
||||
scaffMgr.showSnackBar(snackBar);
|
||||
}
|
||||
} catch (_) {
|
||||
// network error
|
||||
final snackBar = SnackBar(
|
||||
behavior: SnackBarBehavior.floating,
|
||||
content: const Text('Network error'),
|
||||
action: SnackBarAction(
|
||||
label: 'Dismiss',
|
||||
onPressed: () {
|
||||
scaffMgr.hideCurrentSnackBar();
|
||||
},
|
||||
),
|
||||
);
|
||||
|
||||
scaffMgr.hideCurrentSnackBar();
|
||||
scaffMgr.showSnackBar(snackBar);
|
||||
}
|
||||
|
||||
// close popup
|
||||
nav.pop();
|
||||
},
|
||||
child: Text(((widget.info?.isOwner)!)
|
||||
? 'Delete'
|
||||
: 'Leave'),
|
||||
)
|
||||
],
|
||||
));
|
||||
},
|
||||
))
|
||||
]
|
||||
: [],
|
||||
]));
|
||||
}
|
||||
}
|
|
@ -2,10 +2,10 @@ import 'package:flutter/material.dart';
|
|||
import 'package:outbag_app/backend/request.dart';
|
||||
import 'package:outbag_app/backend/room.dart';
|
||||
import 'package:outbag_app/backend/user.dart';
|
||||
import 'package:outbag_app/screens/room/about.dart';
|
||||
import 'package:outbag_app/screens/room/categories.dart';
|
||||
import 'package:outbag_app/screens/room/products.dart';
|
||||
import 'package:outbag_app/screens/room/shopping_list.dart';
|
||||
import 'package:outbag_app/screens/room/pages/about.dart';
|
||||
import 'package:outbag_app/screens/room/pages/categories.dart';
|
||||
import 'package:outbag_app/screens/room/pages/products.dart';
|
||||
import 'package:outbag_app/screens/room/pages/list.dart';
|
||||
import 'package:routemaster/routemaster.dart';
|
||||
|
||||
class RoomPage extends StatefulWidget {
|
||||
|
|
365
lib/screens/room/pages/about.dart
Normal file
365
lib/screens/room/pages/about.dart
Normal file
|
@ -0,0 +1,365 @@
|
|||
import 'package:flutter/material.dart';
|
||||
import 'package:flutter_svg/flutter_svg.dart';
|
||||
import 'package:outbag_app/backend/errors.dart';
|
||||
import 'package:outbag_app/backend/permissions.dart';
|
||||
import 'package:outbag_app/backend/request.dart';
|
||||
import 'package:outbag_app/backend/room.dart';
|
||||
import 'dart:math';
|
||||
|
||||
import 'package:outbag_app/backend/user.dart';
|
||||
import 'package:outbag_app/screens/room/edit.dart';
|
||||
import 'package:routemaster/routemaster.dart';
|
||||
|
||||
class AboutRoomPage extends StatefulWidget {
|
||||
final RoomInfo? info;
|
||||
final Room? room;
|
||||
|
||||
const AboutRoomPage(this.room, this.info, {super.key});
|
||||
|
||||
@override
|
||||
State<StatefulWidget> createState() => _AboutRoomPageState();
|
||||
}
|
||||
|
||||
class _AboutRoomPageState extends State<AboutRoomPage> {
|
||||
@override
|
||||
void initState() {
|
||||
super.initState();
|
||||
}
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
final textTheme = Theme.of(context)
|
||||
.textTheme
|
||||
.apply(displayColor: Theme.of(context).colorScheme.onSurface);
|
||||
|
||||
double width = MediaQuery.of(context).size.width;
|
||||
double height = MediaQuery.of(context).size.height;
|
||||
double smallest = min(width, height);
|
||||
|
||||
return Center(
|
||||
child: Column(children: [
|
||||
// room meta display
|
||||
...(widget.room != null)
|
||||
? [
|
||||
Padding(
|
||||
padding: const EdgeInsets.all(14),
|
||||
child: Column(
|
||||
children: [
|
||||
SvgPicture.asset(
|
||||
(widget.room?.icon?.img)!,
|
||||
width: smallest * 0.2,
|
||||
height: smallest * 0.2,
|
||||
),
|
||||
Text(
|
||||
widget.room?.name ?? '',
|
||||
style: textTheme.displayMedium,
|
||||
),
|
||||
Text(
|
||||
'${widget.room?.id}@${widget.room?.serverTag}',
|
||||
style: textTheme.bodySmall,
|
||||
),
|
||||
Text(widget.room?.description ?? '',
|
||||
style: textTheme.bodyMedium),
|
||||
Padding(
|
||||
padding: const EdgeInsets.all(8),
|
||||
child: SegmentedButton<int>(
|
||||
showSelectedIcon: true,
|
||||
multiSelectionEnabled: false,
|
||||
emptySelectionAllowed: false,
|
||||
segments: RoomVisibility.list().map((vis) {
|
||||
return ButtonSegment<int>(
|
||||
value: vis.type,
|
||||
label: Text(vis.text),
|
||||
icon: Icon(vis.icon));
|
||||
}).toList(),
|
||||
onSelectionChanged: ((vset) {
|
||||
// check permission
|
||||
// only show confirm dialog when user
|
||||
// is admin, owner or has CHANGE_ADMIN permission
|
||||
if (widget.info == null ||
|
||||
(!(widget.info?.isAdmin ?? false) &&
|
||||
!(widget.info?.isOwner ?? false) &&
|
||||
((widget.info?.permissions)! &
|
||||
RoomPermission.ota ==
|
||||
0))) {
|
||||
// action not permitted
|
||||
// NOTE: no error dialog should be shown
|
||||
// because the action is supposed to be hidden
|
||||
return;
|
||||
}
|
||||
|
||||
final vis = RoomVisibility(vset.first);
|
||||
showDialog(
|
||||
context: context,
|
||||
builder: (ctx) => AlertDialog(
|
||||
title:
|
||||
const Text('Change room visibility'),
|
||||
content: Text(
|
||||
'Do you really want to change the room visibility to: ${vis.text}'),
|
||||
actions: [
|
||||
TextButton(
|
||||
onPressed: () {
|
||||
Navigator.of(context).pop();
|
||||
},
|
||||
child: const Text('Cancel'),
|
||||
),
|
||||
FilledButton(
|
||||
onPressed: () async {
|
||||
final scaffMgr =
|
||||
ScaffoldMessenger.of(context);
|
||||
final nav = Navigator.of(context);
|
||||
|
||||
User user;
|
||||
try {
|
||||
user = await User.fromDisk();
|
||||
} catch (_) {
|
||||
// probably not logged in
|
||||
nav.pop();
|
||||
return;
|
||||
}
|
||||
|
||||
try {
|
||||
final resp =
|
||||
await postWithCreadentials(
|
||||
path: 'setVisibility',
|
||||
target: user.server,
|
||||
body: {
|
||||
'room': widget.room?.id,
|
||||
'server': (widget
|
||||
.room?.serverTag)!,
|
||||
'visibility': vset.first
|
||||
},
|
||||
credentials: user);
|
||||
if (resp.res == Result.ok) {
|
||||
Room r = widget.room!;
|
||||
r.visibility = vis;
|
||||
r.toDisk();
|
||||
} else {
|
||||
// server error
|
||||
final snackBar = SnackBar(
|
||||
behavior:
|
||||
SnackBarBehavior.floating,
|
||||
content: Text(
|
||||
errorAsString(resp.body)),
|
||||
action: SnackBarAction(
|
||||
label: 'Dismiss',
|
||||
onPressed: () {
|
||||
scaffMgr
|
||||
.hideCurrentSnackBar();
|
||||
},
|
||||
),
|
||||
);
|
||||
|
||||
scaffMgr.hideCurrentSnackBar();
|
||||
scaffMgr.showSnackBar(snackBar);
|
||||
}
|
||||
} catch (_) {
|
||||
// network error
|
||||
final snackBar = SnackBar(
|
||||
behavior:
|
||||
SnackBarBehavior.floating,
|
||||
content:
|
||||
const Text('Network error'),
|
||||
action: SnackBarAction(
|
||||
label: 'Dismiss',
|
||||
onPressed: () {
|
||||
scaffMgr
|
||||
.hideCurrentSnackBar();
|
||||
},
|
||||
),
|
||||
);
|
||||
|
||||
scaffMgr.hideCurrentSnackBar();
|
||||
scaffMgr.showSnackBar(snackBar);
|
||||
}
|
||||
|
||||
nav.pop();
|
||||
},
|
||||
child: const Text('Ok'),
|
||||
)
|
||||
],
|
||||
));
|
||||
}),
|
||||
selected: {(widget.room?.visibility?.type)!},
|
||||
selectedIcon: Icon((widget.room?.visibility?.icon)!),
|
||||
)),
|
||||
],
|
||||
),
|
||||
)
|
||||
]
|
||||
: [],
|
||||
|
||||
Padding(
|
||||
padding: const EdgeInsets.all(14),
|
||||
child: Column(
|
||||
children: [
|
||||
// edit room meta button
|
||||
...(widget.info != null &&
|
||||
((widget.info?.isAdmin ?? false) ||
|
||||
(widget.info?.isOwner ?? false) ||
|
||||
((widget.info?.permissions)! &
|
||||
RoomPermission.changeMeta !=
|
||||
0)))
|
||||
? [
|
||||
ListTile(
|
||||
trailing: const Icon(Icons.chevron_right),
|
||||
title: const Text('Edit Metadata'),
|
||||
subtitle: const Text(
|
||||
'Change the rooms name, description and icon'),
|
||||
onTap: () {
|
||||
// show edit room screen
|
||||
showDialog(
|
||||
context: context,
|
||||
builder: (context)=>Dialog.fullscreen(
|
||||
child: EditRoomPage(widget.room!),
|
||||
)
|
||||
);
|
||||
},
|
||||
),
|
||||
]
|
||||
: [],
|
||||
// open members view
|
||||
ListTile(
|
||||
trailing: const Icon(Icons.chevron_right),
|
||||
title: const Text('Members'),
|
||||
subtitle: const Text('Show Member list'),
|
||||
onTap: () {
|
||||
// open member view screen
|
||||
Routemaster.of(context).push(
|
||||
'/r/${widget.room?.serverTag}/${widget.room?.id}/members');
|
||||
},
|
||||
),
|
||||
...(widget.info != null &&
|
||||
((widget.info?.isAdmin ?? false) ||
|
||||
(widget.info?.isOwner ?? false) ||
|
||||
((widget.info?.permissions)! & RoomPermission.ota !=
|
||||
0)))
|
||||
? [
|
||||
ListTile(
|
||||
trailing: const Icon(Icons.chevron_right),
|
||||
title: const Text('OTA'),
|
||||
subtitle: const Text('Manage and delete OTAs'),
|
||||
onTap: () {
|
||||
// show manage ota screen
|
||||
Routemaster.of(context).push(
|
||||
'/r/${widget.room?.serverTag}/${widget.room?.id}/ota');
|
||||
},
|
||||
),
|
||||
]
|
||||
: [],
|
||||
],
|
||||
)),
|
||||
|
||||
...(widget.info != null)
|
||||
? [
|
||||
Padding(
|
||||
padding: const EdgeInsets.all(8),
|
||||
child: FilledButton.tonal(
|
||||
child: Text(((widget.info?.isOwner)!)
|
||||
? 'Delete Room'
|
||||
: 'Leave Room'),
|
||||
onPressed: () {
|
||||
// show confirm dialog
|
||||
showDialog(
|
||||
context: context,
|
||||
builder: (ctx) => AlertDialog(
|
||||
title: Text(((widget.info?.isOwner)!)
|
||||
? 'Delete Room'
|
||||
: 'Leave Room'),
|
||||
content: Text(
|
||||
'Do you really want to ${((widget.info?.isOwner)!) ? "delete" : "leave"} the room?'),
|
||||
actions: [
|
||||
TextButton(
|
||||
onPressed: () {
|
||||
// close popup
|
||||
Navigator.of(ctx).pop();
|
||||
},
|
||||
child: const Text('Cancel'),
|
||||
),
|
||||
FilledButton(
|
||||
onPressed: () async {
|
||||
// send request
|
||||
final scaffMgr =
|
||||
ScaffoldMessenger.of(ctx);
|
||||
final nav = Navigator.of(ctx);
|
||||
final rmaster = Routemaster.of(ctx);
|
||||
|
||||
User user;
|
||||
try {
|
||||
user = await User.fromDisk();
|
||||
} catch (_) {
|
||||
// probably not logged in
|
||||
nav.pop();
|
||||
return;
|
||||
}
|
||||
|
||||
try {
|
||||
final resp = await postWithCreadentials(
|
||||
path: ((widget.info?.isOwner)!)
|
||||
? 'deleteRoom'
|
||||
: 'leaveRoom',
|
||||
target: user.server,
|
||||
body: {
|
||||
'room': widget.room?.id,
|
||||
'server':
|
||||
(widget.room?.serverTag)!,
|
||||
},
|
||||
credentials: user);
|
||||
if (resp.res == Result.ok) {
|
||||
// try delete room from disk
|
||||
try {
|
||||
await widget.room?.removeDisk();
|
||||
} catch (_) {}
|
||||
|
||||
// go back home
|
||||
rmaster.replace('/');
|
||||
} else {
|
||||
// server error
|
||||
final snackBar = SnackBar(
|
||||
behavior: SnackBarBehavior.floating,
|
||||
content:
|
||||
Text(errorAsString(resp.body)),
|
||||
action: SnackBarAction(
|
||||
label: 'Dismiss',
|
||||
onPressed: () {
|
||||
scaffMgr.hideCurrentSnackBar();
|
||||
},
|
||||
),
|
||||
);
|
||||
|
||||
scaffMgr.hideCurrentSnackBar();
|
||||
scaffMgr.showSnackBar(snackBar);
|
||||
}
|
||||
} catch (_) {
|
||||
// network error
|
||||
final snackBar = SnackBar(
|
||||
behavior: SnackBarBehavior.floating,
|
||||
content: const Text('Network error'),
|
||||
action: SnackBarAction(
|
||||
label: 'Dismiss',
|
||||
onPressed: () {
|
||||
scaffMgr.hideCurrentSnackBar();
|
||||
},
|
||||
),
|
||||
);
|
||||
|
||||
scaffMgr.hideCurrentSnackBar();
|
||||
scaffMgr.showSnackBar(snackBar);
|
||||
}
|
||||
|
||||
// close popup
|
||||
nav.pop();
|
||||
},
|
||||
child: Text(((widget.info?.isOwner)!)
|
||||
? 'Delete'
|
||||
: 'Leave'),
|
||||
)
|
||||
],
|
||||
));
|
||||
},
|
||||
))
|
||||
]
|
||||
: [],
|
||||
]));
|
||||
}
|
||||
}
|
Loading…
Reference in a new issue