mirror of
https://github.com/Xevion/paperless-mobile.git
synced 2025-12-07 20:07:48 -06:00
feat: Finalize bulk edits and reworked form fields
This commit is contained in:
56
lib/core/widgets/dialog_utils/dialog_confirm_button.dart
Normal file
56
lib/core/widgets/dialog_utils/dialog_confirm_button.dart
Normal 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),
|
||||
);
|
||||
}
|
||||
}
|
||||
@@ -2,6 +2,7 @@ import 'package:flutter/material.dart';
|
||||
import 'package:flutter/services.dart';
|
||||
import 'package:flutter_form_builder/flutter_form_builder.dart';
|
||||
import 'package:paperless_mobile/core/model/github_error_report.model.dart';
|
||||
import 'package:paperless_mobile/core/widgets/dialog_utils/dialog_cancel_button.dart';
|
||||
import 'package:paperless_mobile/extensions/flutter_extensions.dart';
|
||||
|
||||
class ErrorReportPage extends StatefulWidget {
|
||||
@@ -136,10 +137,7 @@ Note: If you have the GitHub Android app installed, the descriptions will not be
|
||||
Navigator.pop(context, true);
|
||||
},
|
||||
),
|
||||
TextButton(
|
||||
child: const Text('Cancel'),
|
||||
onPressed: () => Navigator.pop(context, false),
|
||||
),
|
||||
const DialogCancelButton(),
|
||||
],
|
||||
),
|
||||
) ??
|
||||
|
||||
@@ -4,6 +4,8 @@ import 'package:flutter/material.dart';
|
||||
import 'package:flutter/services.dart';
|
||||
import 'package:flutter_colorpicker/flutter_colorpicker.dart';
|
||||
import 'package:flutter_form_builder/flutter_form_builder.dart';
|
||||
import 'package:paperless_mobile/core/widgets/dialog_utils/dialog_cancel_button.dart';
|
||||
import 'package:paperless_mobile/core/widgets/dialog_utils/dialog_confirm_button.dart';
|
||||
import 'package:paperless_mobile/generated/l10n/app_localizations.dart';
|
||||
|
||||
extension on Color {
|
||||
@@ -136,11 +138,12 @@ class FormBuilderColorPickerField extends FormBuilderField<Color> {
|
||||
: LayoutBuilder(
|
||||
key: ObjectKey(state.value),
|
||||
builder: (context, constraints) {
|
||||
return Icon(
|
||||
Icons.circle,
|
||||
key: ObjectKey(state.value),
|
||||
size: constraints.minHeight,
|
||||
color: state.value,
|
||||
return Padding(
|
||||
padding: const EdgeInsets.all(8.0),
|
||||
child: CircleAvatar(
|
||||
key: ObjectKey(state.value),
|
||||
backgroundColor: state.value,
|
||||
),
|
||||
);
|
||||
},
|
||||
),
|
||||
@@ -218,17 +221,11 @@ class FormBuilderColorPickerFieldState
|
||||
|
||||
return AlertDialog(
|
||||
// title: null, //const Text('Pick a color!'),
|
||||
content: SingleChildScrollView(
|
||||
child: _buildColorPicker(),
|
||||
),
|
||||
content: _buildColorPicker(),
|
||||
actions: <Widget>[
|
||||
TextButton(
|
||||
onPressed: () => Navigator.pop(context, false),
|
||||
child: Text(materialLocalizations.cancel),
|
||||
),
|
||||
TextButton(
|
||||
onPressed: () => Navigator.pop(context, true),
|
||||
child: Text(materialLocalizations.ok),
|
||||
const DialogCancelButton(),
|
||||
DialogConfirmButton(
|
||||
label: S.of(context)!.ok,
|
||||
),
|
||||
],
|
||||
);
|
||||
|
||||
@@ -1,5 +1,7 @@
|
||||
import 'package:flutter/material.dart';
|
||||
import 'package:flutter/scheduler.dart';
|
||||
import 'package:paperless_mobile/extensions/flutter_extensions.dart';
|
||||
import 'package:paperless_mobile/generated/l10n/app_localizations.dart';
|
||||
|
||||
class FullscreenSelectionForm extends StatefulWidget {
|
||||
final FocusNode? focusNode;
|
||||
@@ -115,31 +117,39 @@ class _FullscreenSelectionFormState extends State<FullscreenSelectionForm> {
|
||||
),
|
||||
),
|
||||
),
|
||||
body: Column(
|
||||
children: [
|
||||
Expanded(
|
||||
child: ListView.builder(
|
||||
padding: EdgeInsets.zero,
|
||||
shrinkWrap: true,
|
||||
itemCount: widget.selectionCount,
|
||||
itemBuilder: (BuildContext context, int index) {
|
||||
final highlight =
|
||||
AutocompleteHighlightedOption.of(context) == index;
|
||||
if (highlight) {
|
||||
SchedulerBinding.instance
|
||||
.addPostFrameCallback((Duration timeStamp) {
|
||||
Scrollable.ensureVisible(
|
||||
context,
|
||||
alignment: 0,
|
||||
);
|
||||
});
|
||||
}
|
||||
return widget.selectionBuilder(context, index);
|
||||
},
|
||||
body: Builder(builder: (context) {
|
||||
if (widget.selectionCount == 0) {
|
||||
return Align(
|
||||
alignment: Alignment.topCenter,
|
||||
child: Text(S.of(context)!.noItemsFound).padded(16),
|
||||
);
|
||||
}
|
||||
return Column(
|
||||
children: [
|
||||
Expanded(
|
||||
child: ListView.builder(
|
||||
padding: EdgeInsets.zero,
|
||||
shrinkWrap: true,
|
||||
itemCount: widget.selectionCount,
|
||||
itemBuilder: (BuildContext context, int index) {
|
||||
final highlight =
|
||||
AutocompleteHighlightedOption.of(context) == index;
|
||||
if (highlight) {
|
||||
SchedulerBinding.instance
|
||||
.addPostFrameCallback((Duration timeStamp) {
|
||||
Scrollable.ensureVisible(
|
||||
context,
|
||||
alignment: 0,
|
||||
);
|
||||
});
|
||||
}
|
||||
return widget.selectionBuilder(context, index);
|
||||
},
|
||||
),
|
||||
),
|
||||
),
|
||||
],
|
||||
),
|
||||
],
|
||||
);
|
||||
}),
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user