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')!,
port: prefs.getInt('server-port')!,
tag: prefs.getString('server-tag')!,
host: prefs.getString('server-host')!
);
host: prefs.getString('server-host')!);
}
static Future<void> removeDisk() async {

View file

@ -322,11 +322,17 @@ class RoomMember {
final bool isInvitePending;
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) {
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 {

View file

@ -9,7 +9,8 @@ class CategoryChip extends StatelessWidget {
@override
Widget build(BuildContext context) {
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),
);
}

View file

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

View file

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

View file

@ -39,12 +39,7 @@ class RoomIconPicker extends StatelessWidget {
if (onSelect != null) {
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:flutter_localizations/flutter_localizations.dart';
import 'package:flutter_gen/gen_l10n/app_localizations.dart';
void main() {
WidgetsFlutterBinding.ensureInitialized();
runApp(const OutbagApp());
@ -206,11 +207,9 @@ class _OutbagAppState extends State {
GoRoute(
name: 'settings',
path: 'settings',
builder: (context, state) =>
SettingsPage(
builder: (context, state) => SettingsPage(
refreshTheme: loadTheme,
refreshUser: loadUser
)),
refreshUser: loadUser)),
GoRoute(
path: 'join-room',
name: 'add-room',
@ -220,7 +219,8 @@ class _OutbagAppState extends State {
GoRoute(
path: 'new',
name: 'new-room',
builder: (context, state) => NewRoomPage()),
builder: (context, state) =>
NewRoomPage()),
]),
GoRoute(
name: 'room',
@ -249,58 +249,77 @@ class _OutbagAppState extends State {
EditRoomPermissionSetPage(
state.params['server'] ?? '',
state.params['id'] ?? '')),
GoRoute(
name: 'new-category',
path: 'new-category',
builder: (context, state)=>EditCategoryPage(
builder: (context, state) =>
EditCategoryPage(
state.params['server'] ?? '',
state.params['id'] ?? '')),
GoRoute(
name: 'edit-category',
path: 'edit-category/:category',
builder: (context, state)=>EditCategoryPage(
builder: (context, state) =>
EditCategoryPage(
state.params['server'] ?? '',
state.params['id'] ?? '',
id: int.tryParse(state.params['category'] ?? ''))),
id: int.tryParse(
state.params['category'] ??
''))),
GoRoute(
name: 'new-product',
path: 'new-product',
builder: (context, state)=>EditProductPage(
server: state.params['server'] ?? '',
room: state.params['id'] ?? '',)),
builder: (context, state) =>
EditProductPage(
server:
state.params['server'] ?? '',
room: state.params['id'] ?? '',
)),
GoRoute(
name: 'view-product',
path: 'p/:product',
builder: (context, state)=>ViewProductPage(
server: state.params['server'] ?? '',
builder: (context, state) =>
ViewProductPage(
server:
state.params['server'] ?? '',
room: state.params['id'] ?? '',
product: int.tryParse(state.params['product'] ?? '') ?? 0),
product: int.tryParse(
state.params['product'] ??
'') ??
0),
routes: [
GoRoute(
name: 'edit-product',
path: 'edit',
builder: (context, state)=>EditProductPage(
server: state.params['server'] ?? '',
room: state.params['id'] ?? '',
product: int.tryParse(state.params['product'] ?? ''))),
]
),
builder: (context, state) =>
EditProductPage(
server: state
.params['server'] ??
'',
room: state.params['id'] ??
'',
product: int.tryParse(
state.params[
'product'] ??
''))),
]),
GoRoute(
name: 'new-item',
path: 'new-item',
builder: (context, state) => EditItemPage(
server: state.params['server'] ?? '',
room: state.params['id'] ?? '',)),
server:
state.params['server'] ?? '',
room: state.params['id'] ?? '',
)),
GoRoute(
name: 'edit-item',
path: 'i/:item',
builder: (context, state) => EditItemPage(
server: state.params['server'] ?? '',
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(
leadingIcon: const Icon(Icons.dns),
child: Text(AppLocalizations.of(context)!.serverDashboard),
child: Text(
AppLocalizations.of(context)!.serverDashboard),
onPressed: () {
// show settings screen
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,
crossAxisAlignment: CrossAxisAlignment.center,
children: [
Text(AppLocalizations.of(context)!.noNewRoomsFound, style: textTheme.titleLarge),
Text(AppLocalizations.of(context)!.noNewRoomsFound,
style: textTheme.titleLarge),
],
))
: ListView.builder(
@ -202,8 +203,8 @@ class _JoinRoomPageState extends State {
MainAxisAlignment.center,
children: [
Icon(room.visibility?.icon),
Text((room
.visibility?.text(context))!),
Text((room.visibility
?.text(context))!),
]),
])),
// action buttons
@ -218,7 +219,10 @@ class _JoinRoomPageState extends State {
child: ElevatedButton.icon(
icon:
const Icon(Icons.close),
label: Text(AppLocalizations.of(context)!.cancel),
label: Text(
AppLocalizations.of(
context)!
.cancel),
onPressed: () {
// close sheet
Navigator.pop(context);
@ -231,7 +235,10 @@ class _JoinRoomPageState extends State {
child: FilledButton.icon(
icon:
const Icon(Icons.check),
label: Text(AppLocalizations.of(context)!.joinRoom),
label: Text(
AppLocalizations.of(
context)!
.joinRoom),
onPressed: () async {
final scaffMgr =
ScaffoldMessenger.of(

View file

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

View file

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

View file

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

View file

@ -145,7 +145,10 @@ class _ViewProductPageState extends State<ViewProductPage> {
style: textTheme.titleMedium),
Text(product?.ean ?? ''),
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,
decoration: InputDecoration(
prefixIcon: const Icon(Icons.lock),
labelText: AppLocalizations.of(context)!.inputNewPasswordRepeatLabel,
hintText: AppLocalizations.of(context)!.inputNewPasswordRepeatHint,
helperText:AppLocalizations.of(context)!.inputNewPasswordRepeatHelp,
labelText:
AppLocalizations.of(context)!.inputNewPasswordRepeatLabel,
hintText:
AppLocalizations.of(context)!.inputNewPasswordRepeatHint,
helperText:
AppLocalizations.of(context)!.inputNewPasswordRepeatHelp,
border: const OutlineInputBorder(),
),
),
@ -93,8 +96,7 @@ class _ChangePasswordDialogState extends State<ChangePasswordDialog> {
if (_ctrNewPassword.text.length < 6) {
// password has to be at least 6 characters long
showSimpleSnackbar(scaffMgr,
text: trans!.errorPasswordLength,
action: trans.dismiss);
text: trans!.errorPasswordLength, action: trans.dismiss);
_ctrNewPasswordRepeat.clear();
return;

View file

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