Formatted files using dart format

This commit is contained in:
Jakob Meier 2023-12-22 20:14:36 +01:00
parent 1975d66419
commit b320d51fa1
No known key found for this signature in database
GPG key ID: 66BDC7E6A01A6152
28 changed files with 2466 additions and 2422 deletions

View file

@ -64,8 +64,7 @@ class OutbagServer {
path: prefs.getString('server-path')!, path: prefs.getString('server-path')!,
port: prefs.getInt('server-port')!, port: prefs.getInt('server-port')!,
tag: prefs.getString('server-tag')!, tag: prefs.getString('server-tag')!,
host: prefs.getString('server-host')! host: prefs.getString('server-host')!);
);
} }
static Future<void> removeDisk() async { static Future<void> removeDisk() async {

View file

@ -322,11 +322,17 @@ class RoomMember {
final bool isInvitePending; final bool isInvitePending;
const RoomMember( const RoomMember(
{required this.id, required this.serverTag, required this.isAdmin, this.isInvitePending=false}); {required this.id,
required this.serverTag,
required this.isAdmin,
this.isInvitePending = false});
factory RoomMember.fromJSON(dynamic json) { factory RoomMember.fromJSON(dynamic json) {
return RoomMember( return RoomMember(
id: json['name'], serverTag: json['server'], isAdmin: json['admin'], isInvitePending: json['confirmed']); id: json['name'],
serverTag: json['server'],
isAdmin: json['admin'],
isInvitePending: json['confirmed']);
} }
String get humanReadableName { String get humanReadableName {

View file

@ -9,7 +9,8 @@ class CategoryChip extends StatelessWidget {
@override @override
Widget build(BuildContext context) { Widget build(BuildContext context) {
return ActionChip( return ActionChip(
avatar: Icon(Icons.square_rounded, color: category?.color ?? RoomCategory.other(context).color), avatar: Icon(Icons.square_rounded,
color: category?.color ?? RoomCategory.other(context).color),
label: Text(category?.name ?? RoomCategory.other(context).name), label: Text(category?.name ?? RoomCategory.other(context).name),
); );
} }

View file

@ -29,13 +29,10 @@ class CategoryPicker extends StatelessWidget {
decoration: InputDecoration( decoration: InputDecoration(
label: label == null ? null : Text(label!), label: label == null ? null : Text(label!),
border: const OutlineInputBorder(), border: const OutlineInputBorder(),
prefixIcon: const Icon(Icons.category) prefixIcon: const Icon(Icons.category)),
),
value: selected, value: selected,
items: [ items: [...categories, RoomCategory.other(context)]
...categories, .map((category) => DropdownMenuItem<int?>(
RoomCategory.other(context)
].map((category)=>DropdownMenuItem<int?>(
value: category.id, value: category.id,
child: Row( child: Row(
mainAxisAlignment: MainAxisAlignment.spaceBetween, mainAxisAlignment: MainAxisAlignment.spaceBetween,
@ -43,16 +40,17 @@ class CategoryPicker extends StatelessWidget {
children: [ children: [
Text(category.name), Text(category.name),
Icon(Icons.square_rounded, Icon(Icons.square_rounded,
color:category.color, color: category.color, size: 32)
size: 32) ]),
] ))
), .toList(),
)).toList(), onChanged: enabled
onChanged: enabled?(cid) { ? (cid) {
if (onSelect != null) { if (onSelect != null) {
onSelect!(cid); onSelect!(cid);
} }
}:null, }
: null,
)); ));
} }
} }

View file

@ -6,14 +6,10 @@ class LabeledDivider extends StatelessWidget {
@override @override
Widget build(BuildContext context) { Widget build(BuildContext context) {
return Row( return Row(children: [
children: [
const Expanded(child: Divider()), const Expanded(child: Divider()),
Padding( Padding(padding: const EdgeInsets.all(8), child: Text(label)),
padding: const EdgeInsets.all(8),
child: Text(label)),
const Expanded(child: Divider()), const Expanded(child: Divider()),
] ]);
);
} }
} }

View file

@ -39,12 +39,7 @@ class RoomIconPicker extends StatelessWidget {
if (onSelect != null) { if (onSelect != null) {
onSelect!(icon); onSelect!(icon);
} }
} }));
) }).toList())));
);
}).toList()
)
)
);
} }
} }

View file

@ -25,6 +25,7 @@ import 'package:outbag_app/screens/settings/main.dart';
import 'package:provider/provider.dart'; import 'package:provider/provider.dart';
import 'package:flutter_localizations/flutter_localizations.dart'; import 'package:flutter_localizations/flutter_localizations.dart';
import 'package:flutter_gen/gen_l10n/app_localizations.dart'; import 'package:flutter_gen/gen_l10n/app_localizations.dart';
void main() { void main() {
WidgetsFlutterBinding.ensureInitialized(); WidgetsFlutterBinding.ensureInitialized();
runApp(const OutbagApp()); runApp(const OutbagApp());
@ -206,11 +207,9 @@ class _OutbagAppState extends State {
GoRoute( GoRoute(
name: 'settings', name: 'settings',
path: 'settings', path: 'settings',
builder: (context, state) => builder: (context, state) => SettingsPage(
SettingsPage(
refreshTheme: loadTheme, refreshTheme: loadTheme,
refreshUser: loadUser refreshUser: loadUser)),
)),
GoRoute( GoRoute(
path: 'join-room', path: 'join-room',
name: 'add-room', name: 'add-room',
@ -220,7 +219,8 @@ class _OutbagAppState extends State {
GoRoute( GoRoute(
path: 'new', path: 'new',
name: 'new-room', name: 'new-room',
builder: (context, state) => NewRoomPage()), builder: (context, state) =>
NewRoomPage()),
]), ]),
GoRoute( GoRoute(
name: 'room', name: 'room',
@ -249,58 +249,77 @@ class _OutbagAppState extends State {
EditRoomPermissionSetPage( EditRoomPermissionSetPage(
state.params['server'] ?? '', state.params['server'] ?? '',
state.params['id'] ?? '')), state.params['id'] ?? '')),
GoRoute( GoRoute(
name: 'new-category', name: 'new-category',
path: 'new-category', path: 'new-category',
builder: (context, state)=>EditCategoryPage( builder: (context, state) =>
EditCategoryPage(
state.params['server'] ?? '', state.params['server'] ?? '',
state.params['id'] ?? '')), state.params['id'] ?? '')),
GoRoute( GoRoute(
name: 'edit-category', name: 'edit-category',
path: 'edit-category/:category', path: 'edit-category/:category',
builder: (context, state)=>EditCategoryPage( builder: (context, state) =>
EditCategoryPage(
state.params['server'] ?? '', state.params['server'] ?? '',
state.params['id'] ?? '', state.params['id'] ?? '',
id: int.tryParse(state.params['category'] ?? ''))), id: int.tryParse(
state.params['category'] ??
''))),
GoRoute( GoRoute(
name: 'new-product', name: 'new-product',
path: 'new-product', path: 'new-product',
builder: (context, state)=>EditProductPage( builder: (context, state) =>
server: state.params['server'] ?? '', EditProductPage(
room: state.params['id'] ?? '',)), server:
state.params['server'] ?? '',
room: state.params['id'] ?? '',
)),
GoRoute( GoRoute(
name: 'view-product', name: 'view-product',
path: 'p/:product', path: 'p/:product',
builder: (context, state)=>ViewProductPage( builder: (context, state) =>
server: state.params['server'] ?? '', ViewProductPage(
server:
state.params['server'] ?? '',
room: state.params['id'] ?? '', room: state.params['id'] ?? '',
product: int.tryParse(state.params['product'] ?? '') ?? 0), product: int.tryParse(
state.params['product'] ??
'') ??
0),
routes: [ routes: [
GoRoute( GoRoute(
name: 'edit-product', name: 'edit-product',
path: 'edit', path: 'edit',
builder: (context, state)=>EditProductPage( builder: (context, state) =>
server: state.params['server'] ?? '', EditProductPage(
room: state.params['id'] ?? '', server: state
product: int.tryParse(state.params['product'] ?? ''))), .params['server'] ??
] '',
), room: state.params['id'] ??
'',
product: int.tryParse(
state.params[
'product'] ??
''))),
]),
GoRoute( GoRoute(
name: 'new-item', name: 'new-item',
path: 'new-item', path: 'new-item',
builder: (context, state) => EditItemPage( builder: (context, state) => EditItemPage(
server: state.params['server'] ?? '', server:
room: state.params['id'] ?? '',)), state.params['server'] ?? '',
room: state.params['id'] ?? '',
)),
GoRoute( GoRoute(
name: 'edit-item', name: 'edit-item',
path: 'i/:item', path: 'i/:item',
builder: (context, state) => EditItemPage( builder: (context, state) => EditItemPage(
server: state.params['server'] ?? '', server: state.params['server'] ?? '',
room: state.params['id'] ?? '', room: state.params['id'] ?? '',
item: int.tryParse(state.params['item'] ?? '') ?? 0), item: int.tryParse(
state.params['item'] ?? '') ??
0),
) )
]) ])
]), ]),

View file

@ -104,7 +104,8 @@ class _HomePageState extends State<HomePage> {
? [ ? [
MenuItemButton( MenuItemButton(
leadingIcon: const Icon(Icons.dns), leadingIcon: const Icon(Icons.dns),
child: Text(AppLocalizations.of(context)!.serverDashboard), child: Text(
AppLocalizations.of(context)!.serverDashboard),
onPressed: () { onPressed: () {
// show settings screen // show settings screen
context.goNamed('dash'); context.goNamed('dash');

View file

@ -0,0 +1 @@

View file

@ -0,0 +1 @@

View file

@ -147,7 +147,8 @@ class _JoinRoomPageState extends State {
mainAxisAlignment: MainAxisAlignment.center, mainAxisAlignment: MainAxisAlignment.center,
crossAxisAlignment: CrossAxisAlignment.center, crossAxisAlignment: CrossAxisAlignment.center,
children: [ children: [
Text(AppLocalizations.of(context)!.noNewRoomsFound, style: textTheme.titleLarge), Text(AppLocalizations.of(context)!.noNewRoomsFound,
style: textTheme.titleLarge),
], ],
)) ))
: ListView.builder( : ListView.builder(
@ -202,8 +203,8 @@ class _JoinRoomPageState extends State {
MainAxisAlignment.center, MainAxisAlignment.center,
children: [ children: [
Icon(room.visibility?.icon), Icon(room.visibility?.icon),
Text((room Text((room.visibility
.visibility?.text(context))!), ?.text(context))!),
]), ]),
])), ])),
// action buttons // action buttons
@ -218,7 +219,10 @@ class _JoinRoomPageState extends State {
child: ElevatedButton.icon( child: ElevatedButton.icon(
icon: icon:
const Icon(Icons.close), const Icon(Icons.close),
label: Text(AppLocalizations.of(context)!.cancel), label: Text(
AppLocalizations.of(
context)!
.cancel),
onPressed: () { onPressed: () {
// close sheet // close sheet
Navigator.pop(context); Navigator.pop(context);
@ -231,7 +235,10 @@ class _JoinRoomPageState extends State {
child: FilledButton.icon( child: FilledButton.icon(
icon: icon:
const Icon(Icons.check), const Icon(Icons.check),
label: Text(AppLocalizations.of(context)!.joinRoom), label: Text(
AppLocalizations.of(
context)!
.joinRoom),
onPressed: () async { onPressed: () async {
final scaffMgr = final scaffMgr =
ScaffoldMessenger.of( ScaffoldMessenger.of(

View file

@ -76,10 +76,7 @@ class _RoomPageState extends State<RoomPage> {
void initState() { void initState() {
super.initState(); super.initState();
room = Room( room = Room(id: widget.tag, serverTag: widget.server);
id: widget.tag,
serverTag: widget.server
);
_ctr.addListener(() { _ctr.addListener(() {
setState(() { setState(() {

View file

@ -282,7 +282,6 @@ class _NewRoomPageState extends State<NewRoomPage> {
await clone.toDisk(); await clone.toDisk();
nav.pop(); nav.pop();
}); });
} else { } else {
// new room specific tests & request // new room specific tests & request
@ -325,7 +324,6 @@ class _NewRoomPageState extends State<NewRoomPage> {
router.pushReplacementNamed('home'); router.pushReplacementNamed('home');
}); });
} }
}, },
label: Text(isEditPage() label: Text(isEditPage()
? AppLocalizations.of(context)!.editRoomMetadataShort ? AppLocalizations.of(context)!.editRoomMetadataShort

View file

@ -91,14 +91,20 @@ class _AboutRoomPageState extends State<AboutRoomPage> {
showDialog( showDialog(
context: context, context: context,
builder: (ctx) => AlertDialog( builder: (ctx) => AlertDialog(
title: Text(AppLocalizations.of(context)!.changeRoomVisibilityTitle), title: Text(AppLocalizations.of(context)!
content: Text(AppLocalizations.of(context)!.changeRoomVisibilitySubtitle(vis.text(context))), .changeRoomVisibilityTitle),
content: Text(
AppLocalizations.of(context)!
.changeRoomVisibilitySubtitle(
vis.text(context))),
actions: [ actions: [
TextButton( TextButton(
onPressed: () { onPressed: () {
context.pop(); context.pop();
}, },
child: Text(AppLocalizations.of(context)!.cancel), child: Text(
AppLocalizations.of(context)!
.cancel),
), ),
FilledButton( FilledButton(
onPressed: () async { onPressed: () async {
@ -127,7 +133,8 @@ class _AboutRoomPageState extends State<AboutRoomPage> {
nav.pop(); nav.pop();
}); });
}, },
child: Text(AppLocalizations.of(context)!.ok), child: Text(
AppLocalizations.of(context)!.ok),
) )
], ],
)); ));
@ -155,8 +162,10 @@ class _AboutRoomPageState extends State<AboutRoomPage> {
? [ ? [
ListTile( ListTile(
trailing: const Icon(Icons.chevron_right), trailing: const Icon(Icons.chevron_right),
title: Text(AppLocalizations.of(context)!.editRoomMetadata), title: Text(
subtitle: Text(AppLocalizations.of(context)!.editRoomMetadataSubtitle), AppLocalizations.of(context)!.editRoomMetadata),
subtitle: Text(AppLocalizations.of(context)!
.editRoomMetadataSubtitle),
onTap: () { onTap: () {
// show edit room screen // show edit room screen
context.goNamed('edit-room', params: { context.goNamed('edit-room', params: {
@ -171,7 +180,8 @@ class _AboutRoomPageState extends State<AboutRoomPage> {
ListTile( ListTile(
trailing: const Icon(Icons.chevron_right), trailing: const Icon(Icons.chevron_right),
title: Text(AppLocalizations.of(context)!.showRoomMembers), title: Text(AppLocalizations.of(context)!.showRoomMembers),
subtitle: Text(AppLocalizations.of(context)!.showRoomMembersSubtitle), subtitle:
Text(AppLocalizations.of(context)!.showRoomMembersSubtitle),
onTap: () { onTap: () {
// open member view screen // open member view screen
context.goNamed('room-members', params: { context.goNamed('room-members', params: {
@ -190,8 +200,10 @@ class _AboutRoomPageState extends State<AboutRoomPage> {
? [ ? [
ListTile( ListTile(
trailing: const Icon(Icons.chevron_right), trailing: const Icon(Icons.chevron_right),
title: Text(AppLocalizations.of(context)!.editRoomPermissions), title: Text(
subtitle: Text(AppLocalizations.of(context)!.editRoomPermissionsSubtitle), AppLocalizations.of(context)!.editRoomPermissions),
subtitle: Text(AppLocalizations.of(context)!
.editRoomPermissionsSubtitle),
onTap: () { onTap: () {
// show checkbox screen // show checkbox screen
context.goNamed('room-permissions', params: { context.goNamed('room-permissions', params: {
@ -210,8 +222,10 @@ class _AboutRoomPageState extends State<AboutRoomPage> {
? [ ? [
ListTile( ListTile(
trailing: const Icon(Icons.chevron_right), trailing: const Icon(Icons.chevron_right),
title: Text(AppLocalizations.of(context)!.manageRoomOTA), title:
subtitle: Text(AppLocalizations.of(context)!.manageRoomOTASubtitle), Text(AppLocalizations.of(context)!.manageRoomOTA),
subtitle: Text(AppLocalizations.of(context)!
.manageRoomOTASubtitle),
onTap: () { onTap: () {
// show manage ota screen // show manage ota screen
context.goNamed('room-ota', params: { context.goNamed('room-ota', params: {
@ -222,8 +236,10 @@ class _AboutRoomPageState extends State<AboutRoomPage> {
), ),
ListTile( ListTile(
trailing: const Icon(Icons.chevron_right), trailing: const Icon(Icons.chevron_right),
title: Text(AppLocalizations.of(context)!.manageRoomInvites), title: Text(
subtitle: Text(AppLocalizations.of(context)!.manageRoomInvitesSubtitle), AppLocalizations.of(context)!.manageRoomInvites),
subtitle: Text(AppLocalizations.of(context)!
.manageRoomInvitesSubtitle),
onTap: () { onTap: () {
// show manage ota screen // show manage ota screen
context.goNamed('room-invite', params: { context.goNamed('room-invite', params: {
@ -254,15 +270,18 @@ class _AboutRoomPageState extends State<AboutRoomPage> {
? AppLocalizations.of(context)!.deleteRoom ? AppLocalizations.of(context)!.deleteRoom
: AppLocalizations.of(context)!.leaveRoom), : AppLocalizations.of(context)!.leaveRoom),
content: Text(((widget.info?.isOwner)!) content: Text(((widget.info?.isOwner)!)
? AppLocalizations.of(context)!.deleteRoomConfirm ? AppLocalizations.of(context)!
: AppLocalizations.of(context)!.leaveRoomConfirm), .deleteRoomConfirm
: AppLocalizations.of(context)!
.leaveRoomConfirm),
actions: [ actions: [
TextButton( TextButton(
onPressed: () { onPressed: () {
// close popup // close popup
Navigator.of(ctx).pop(); Navigator.of(ctx).pop();
}, },
child: Text(AppLocalizations.of(context)!.cancel), child: Text(
AppLocalizations.of(context)!.cancel),
), ),
FilledButton( FilledButton(
onPressed: () async { onPressed: () async {
@ -300,8 +319,10 @@ class _AboutRoomPageState extends State<AboutRoomPage> {
}); });
}, },
child: Text(((widget.info?.isOwner)!) child: Text(((widget.info?.isOwner)!)
? AppLocalizations.of(context)!.deleteRoomShort ? AppLocalizations.of(context)!
: AppLocalizations.of(context)!.leaveRoomShort), .deleteRoomShort
: AppLocalizations.of(context)!
.leaveRoomShort),
) )
], ],
)); ));

View file

@ -233,9 +233,11 @@ class _RoomCategoriesPageState extends State<RoomCategoriesPage> {
}); });
}, },
), ),
floatingActionButton: (widget.info != null && ((widget.info?.isAdmin ?? false) || floatingActionButton: (widget.info != null &&
((widget.info?.isAdmin ?? false) ||
(widget.info?.isOwner ?? false) || (widget.info?.isOwner ?? false) ||
((widget.info?.permissions)! & RoomPermission.editRoomContent != ((widget.info?.permissions)! &
RoomPermission.editRoomContent !=
0))) 0)))
? FloatingActionButton.extended( ? FloatingActionButton.extended(
icon: const Icon(Icons.add), icon: const Icon(Icons.add),

View file

@ -81,9 +81,11 @@ class _RoomProductsPageState extends State<RoomProductsPage> {
); );
}, },
), ),
floatingActionButton: (widget.info != null && ((widget.info?.isAdmin ?? false) || floatingActionButton: (widget.info != null &&
((widget.info?.isAdmin ?? false) ||
(widget.info?.isOwner ?? false) || (widget.info?.isOwner ?? false) ||
((widget.info?.permissions)! & RoomPermission.editRoomContent != ((widget.info?.permissions)! &
RoomPermission.editRoomContent !=
0))) 0)))
? FloatingActionButton.extended( ? FloatingActionButton.extended(
icon: const Icon(Icons.add), icon: const Icon(Icons.add),

View file

@ -145,7 +145,10 @@ class _ViewProductPageState extends State<ViewProductPage> {
style: textTheme.titleMedium), style: textTheme.titleMedium),
Text(product?.ean ?? ''), Text(product?.ean ?? ''),
CategoryChip(category: categories[product?.category]), CategoryChip(category: categories[product?.category]),
Text(product!=null?Unit.fromId(product!.defaultUnit).display(context, product!.defaultValue):'') Text(product != null
? Unit.fromId(product!.defaultUnit)
.display(context, product!.defaultValue)
: '')
], ],
))), ))),

View file

@ -0,0 +1 @@

View file

@ -65,9 +65,12 @@ class _ChangePasswordDialogState extends State<ChangePasswordDialog> {
obscureText: true, obscureText: true,
decoration: InputDecoration( decoration: InputDecoration(
prefixIcon: const Icon(Icons.lock), prefixIcon: const Icon(Icons.lock),
labelText: AppLocalizations.of(context)!.inputNewPasswordRepeatLabel, labelText:
hintText: AppLocalizations.of(context)!.inputNewPasswordRepeatHint, AppLocalizations.of(context)!.inputNewPasswordRepeatLabel,
helperText:AppLocalizations.of(context)!.inputNewPasswordRepeatHelp, hintText:
AppLocalizations.of(context)!.inputNewPasswordRepeatHint,
helperText:
AppLocalizations.of(context)!.inputNewPasswordRepeatHelp,
border: const OutlineInputBorder(), border: const OutlineInputBorder(),
), ),
), ),
@ -93,8 +96,7 @@ class _ChangePasswordDialogState extends State<ChangePasswordDialog> {
if (_ctrNewPassword.text.length < 6) { if (_ctrNewPassword.text.length < 6) {
// password has to be at least 6 characters long // password has to be at least 6 characters long
showSimpleSnackbar(scaffMgr, showSimpleSnackbar(scaffMgr,
text: trans!.errorPasswordLength, text: trans!.errorPasswordLength, action: trans.dismiss);
action: trans.dismiss);
_ctrNewPasswordRepeat.clear(); _ctrNewPasswordRepeat.clear();
return; return;

View file

@ -70,10 +70,8 @@ class _WelcomePageState extends State<WelcomePage> {
AppLocalizations.of(context)!.welcomeTitle, AppLocalizations.of(context)!.welcomeTitle,
style: textTheme.displaySmall, style: textTheme.displaySmall,
), ),
Text( Text(AppLocalizations.of(context)!.welcomeSubtitle,
AppLocalizations.of(context)!.welcomeSubtitle, style: textTheme.bodyMedium)
style: textTheme.bodyMedium
)
], ],
), ),
Column( Column(
@ -88,8 +86,7 @@ class _WelcomePageState extends State<WelcomePage> {
AppLocalizations.of(context)!.page2Title, AppLocalizations.of(context)!.page2Title,
style: textTheme.displaySmall, style: textTheme.displaySmall,
), ),
Text( Text(AppLocalizations.of(context)!.page2Subtitle,
AppLocalizations.of(context)!.page2Subtitle,
style: textTheme.bodyMedium) style: textTheme.bodyMedium)
], ],
), ),
@ -105,8 +102,7 @@ class _WelcomePageState extends State<WelcomePage> {
AppLocalizations.of(context)!.page3Title, AppLocalizations.of(context)!.page3Title,
style: textTheme.displaySmall, style: textTheme.displaySmall,
), ),
Text( Text(AppLocalizations.of(context)!.page3Subtitle,
AppLocalizations.of(context)!.page3Subtitle,
style: textTheme.bodyMedium) style: textTheme.bodyMedium)
], ],
), ),
@ -122,8 +118,7 @@ class _WelcomePageState extends State<WelcomePage> {
AppLocalizations.of(context)!.page4Title, AppLocalizations.of(context)!.page4Title,
style: textTheme.displaySmall, style: textTheme.displaySmall,
), ),
Text( Text(AppLocalizations.of(context)!.page4Subtitle,
AppLocalizations.of(context)!.page4Subtitle,
style: textTheme.bodyMedium) style: textTheme.bodyMedium)
], ],
), ),
@ -133,8 +128,7 @@ class _WelcomePageState extends State<WelcomePage> {
onPressed: () { onPressed: () {
context.goNamed('signin'); context.goNamed('signin');
}, },
child: Text(AppLocalizations.of(context)!.userHasAnAccount child: Text(AppLocalizations.of(context)!.userHasAnAccount),
),
) )
], ],
), ),