refactor: extract invoice approval and dispute logic into a dedicated ShiftCompletionReviewBloc.
This commit is contained in:
@@ -3,7 +3,6 @@ import '../ui_constants.dart';
|
||||
|
||||
/// A custom button widget with different variants and icon support.
|
||||
class UiButton extends StatelessWidget {
|
||||
|
||||
/// Creates a [UiButton] with a custom button builder.
|
||||
const UiButton({
|
||||
super.key,
|
||||
@@ -17,6 +16,7 @@ class UiButton extends StatelessWidget {
|
||||
this.iconSize = 20,
|
||||
this.size = UiButtonSize.large,
|
||||
this.fullWidth = false,
|
||||
this.isLoading = false,
|
||||
}) : assert(
|
||||
text != null || child != null,
|
||||
'Either text or child must be provided',
|
||||
@@ -34,6 +34,7 @@ class UiButton extends StatelessWidget {
|
||||
this.iconSize = 20,
|
||||
this.size = UiButtonSize.large,
|
||||
this.fullWidth = false,
|
||||
this.isLoading = false,
|
||||
}) : buttonBuilder = _elevatedButtonBuilder,
|
||||
assert(
|
||||
text != null || child != null,
|
||||
@@ -50,8 +51,9 @@ class UiButton extends StatelessWidget {
|
||||
this.trailingIcon,
|
||||
this.style,
|
||||
this.iconSize = 20,
|
||||
this.size = UiButtonSize.large,
|
||||
this.size = UiButtonSize.large,
|
||||
this.fullWidth = false,
|
||||
this.isLoading = false,
|
||||
}) : buttonBuilder = _outlinedButtonBuilder,
|
||||
assert(
|
||||
text != null || child != null,
|
||||
@@ -70,6 +72,7 @@ class UiButton extends StatelessWidget {
|
||||
this.iconSize = 20,
|
||||
this.size = UiButtonSize.large,
|
||||
this.fullWidth = false,
|
||||
this.isLoading = false,
|
||||
}) : buttonBuilder = _textButtonBuilder,
|
||||
assert(
|
||||
text != null || child != null,
|
||||
@@ -88,11 +91,13 @@ class UiButton extends StatelessWidget {
|
||||
this.iconSize = 20,
|
||||
this.size = UiButtonSize.large,
|
||||
this.fullWidth = false,
|
||||
this.isLoading = false,
|
||||
}) : buttonBuilder = _textButtonBuilder,
|
||||
assert(
|
||||
text != null || child != null,
|
||||
'Either text or child must be provided',
|
||||
);
|
||||
|
||||
/// The text to display on the button.
|
||||
final String? text;
|
||||
|
||||
@@ -129,18 +134,21 @@ class UiButton extends StatelessWidget {
|
||||
)
|
||||
buttonBuilder;
|
||||
|
||||
/// Whether to show a loading indicator.
|
||||
final bool isLoading;
|
||||
|
||||
@override
|
||||
/// Builds the button UI.
|
||||
Widget build(BuildContext context) {
|
||||
final ButtonStyle mergedStyle = style != null
|
||||
? _getSizeStyle().merge(style)
|
||||
final ButtonStyle mergedStyle = style != null
|
||||
? _getSizeStyle().merge(style)
|
||||
: _getSizeStyle();
|
||||
|
||||
|
||||
final Widget button = buttonBuilder(
|
||||
context,
|
||||
onPressed,
|
||||
isLoading ? null : onPressed,
|
||||
mergedStyle,
|
||||
_buildButtonContent(),
|
||||
isLoading ? _buildLoadingContent() : _buildButtonContent(),
|
||||
);
|
||||
|
||||
if (fullWidth) {
|
||||
@@ -150,6 +158,15 @@ class UiButton extends StatelessWidget {
|
||||
return button;
|
||||
}
|
||||
|
||||
/// Builds the loading indicator.
|
||||
Widget _buildLoadingContent() {
|
||||
return const SizedBox(
|
||||
height: 20,
|
||||
width: 20,
|
||||
child: CircularProgressIndicator(strokeWidth: 2),
|
||||
);
|
||||
}
|
||||
|
||||
/// Gets the style based on the button size.
|
||||
ButtonStyle _getSizeStyle() {
|
||||
switch (size) {
|
||||
|
||||
Reference in New Issue
Block a user