feat: Finalize bulk edits and reworked form fields

This commit is contained in:
Anton Stubenbord
2023-04-13 22:43:41 +02:00
parent 83d8abeae2
commit d621a3bbe7
41 changed files with 936 additions and 995 deletions

View File

@@ -0,0 +1,56 @@
import 'package:flutter/material.dart';
import 'package:flutter/src/widgets/framework.dart';
import 'package:flutter/src/widgets/placeholder.dart';
import 'package:paperless_mobile/generated/l10n/app_localizations.dart';
enum DialogConfirmButtonStyle {
normal,
danger;
}
class DialogConfirmButton<T> extends StatelessWidget {
final DialogConfirmButtonStyle style;
final String? label;
final T? returnValue;
const DialogConfirmButton({
super.key,
this.style = DialogConfirmButtonStyle.normal,
this.label,
this.returnValue,
});
@override
Widget build(BuildContext context) {
final _normalStyle = ButtonStyle(
backgroundColor: MaterialStatePropertyAll(
Theme.of(context).colorScheme.primaryContainer,
),
foregroundColor: MaterialStatePropertyAll(
Theme.of(context).colorScheme.onPrimaryContainer,
),
);
final _dangerStyle = ButtonStyle(
backgroundColor: MaterialStatePropertyAll(
Theme.of(context).colorScheme.errorContainer,
),
foregroundColor: MaterialStatePropertyAll(
Theme.of(context).colorScheme.onErrorContainer,
),
);
late final ButtonStyle _style;
switch (style) {
case DialogConfirmButtonStyle.normal:
_style = _normalStyle;
break;
case DialogConfirmButtonStyle.danger:
_style = _dangerStyle;
break;
}
return ElevatedButton(
child: Text(label ?? S.of(context)!.confirm),
style: _style,
onPressed: () => Navigator.of(context).pop(returnValue ?? true),
);
}
}