Skip to content

Commit

Permalink
feat: dialog added loading indicators, loading indicator added color
Browse files Browse the repository at this point in the history
  • Loading branch information
vanlooverenkoen committed Aug 29, 2024
1 parent e2d5607 commit 9945365
Show file tree
Hide file tree
Showing 4 changed files with 61 additions and 23 deletions.
7 changes: 5 additions & 2 deletions lib/src/components/button/impaktfull_button.dart
Original file line number Diff line number Diff line change
Expand Up @@ -77,9 +77,12 @@ class _ImpaktfullButtonState extends State<ImpaktfullButton> {
onTap: hasOnTap ? _onTap : null,
color: background,
shadow: [
if (theme.shadows.button != null && widget._type != _ButtonType.secondary) theme.shadows.button!,
if (theme.shadows.button != null &&
widget._type != _ButtonType.secondary)
theme.shadows.button!,
],
borderRadius: BorderRadius.circular(theme.dimens.generalBorderRadius),
borderRadius:
BorderRadius.circular(theme.dimens.generalBorderRadius),
child: Container(
constraints: const BoxConstraints(
minWidth: 48,
Expand Down
59 changes: 43 additions & 16 deletions lib/src/components/dialog/impaktfull_dialog.dart
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,8 @@ class ImpaktfullDialog extends StatelessWidget {
padding: padding,
decoration: BoxDecoration(
color: theme.colors.card,
borderRadius: BorderRadius.circular(theme.dimens.generalBorderRadius),
borderRadius:
BorderRadius.circular(theme.dimens.generalBorderRadius),
),
child: Column(
mainAxisSize: MainAxisSize.min,
Expand All @@ -67,35 +68,61 @@ class ImpaktfullDialog extends StatelessWidget {
if (onSecondaryTapped != null) ...[
Expanded(
child: ImpaktfullButton.secondary(
label: secondaryLabel ?? theme.localizations.current.generalLabelCancel,
onTap: onSecondaryTapped is AsyncCallback ? null : onSecondaryTapped as VoidCallback,
onAsyncTap: onSecondaryTapped is AsyncCallback ? onSecondaryTapped as AsyncCallback : null,
label: secondaryLabel ??
theme.localizations.current.generalLabelCancel,
onTap: onSecondaryTapped is AsyncCallback
? null
: onSecondaryTapped as VoidCallback,
onAsyncTap: onSecondaryTapped is AsyncCallback
? onSecondaryTapped as AsyncCallback
: null,
),
),
],
if (onPrimaryTapped != null) ...[
if (primaryButtonType == ImpaktfullDialogPrimaryButtonType.primary) ...[
if (primaryButtonType ==
ImpaktfullDialogPrimaryButtonType.primary) ...[
Expanded(
child: ImpaktfullButton.primary(
label: primaryLabel ?? theme.localizations.current.generalLabelAccept,
onTap: onPrimaryTapped is AsyncCallback ? null : onPrimaryTapped as VoidCallback,
onAsyncTap: onPrimaryTapped is AsyncCallback ? onPrimaryTapped as AsyncCallback : null,
label: primaryLabel ??
theme
.localizations.current.generalLabelAccept,
onTap: onPrimaryTapped is AsyncCallback
? null
: onPrimaryTapped as VoidCallback,
onAsyncTap: onPrimaryTapped is AsyncCallback
? onPrimaryTapped as AsyncCallback
: null,
),
),
] else if (primaryButtonType == ImpaktfullDialogPrimaryButtonType.accent) ...[
] else if (primaryButtonType ==
ImpaktfullDialogPrimaryButtonType.accent) ...[
Expanded(
child: ImpaktfullButton.accent(
label: primaryLabel ?? theme.localizations.current.generalLabelAccept,
onTap: onPrimaryTapped is AsyncCallback ? null : onPrimaryTapped as VoidCallback,
onAsyncTap: onPrimaryTapped is AsyncCallback ? onPrimaryTapped as AsyncCallback : null,
label: primaryLabel ??
theme
.localizations.current.generalLabelAccept,
onTap: onPrimaryTapped is AsyncCallback
? null
: onPrimaryTapped as VoidCallback,
onAsyncTap: onPrimaryTapped is AsyncCallback
? onPrimaryTapped as AsyncCallback
: null,
),
),
] else if (primaryButtonType == ImpaktfullDialogPrimaryButtonType.danger) ...[
] else if (primaryButtonType ==
ImpaktfullDialogPrimaryButtonType.danger) ...[
Expanded(
child: ImpaktfullButton.danger(
label: primaryLabel ?? theme.localizations.current.generalLabelAccept,
onTap: onPrimaryTapped is AsyncCallback ? null : onPrimaryTapped as VoidCallback,
onAsyncTap: onPrimaryTapped is AsyncCallback ? onPrimaryTapped as AsyncCallback : null,
label: primaryLabel ??
theme
.localizations.current.generalLabelAccept,
onTap: onPrimaryTapped is AsyncCallback
? null
: onPrimaryTapped as VoidCallback,
onAsyncTap: onPrimaryTapped is AsyncCallback
? onPrimaryTapped as AsyncCallback
: null,
),
),
],
Expand Down
12 changes: 8 additions & 4 deletions lib/src/components/input_field/impaktfull_input_field.dart
Original file line number Diff line number Diff line change
Expand Up @@ -36,20 +36,23 @@ class ImpaktfullInputField extends StatefulWidget {
class _ImpaktfullInputFieldState extends State<ImpaktfullInputField> {
TextEditingController? _internalTextEditingController;

TextEditingController get _textEditingController => _internalTextEditingController ?? widget.controller!;
TextEditingController get _textEditingController =>
_internalTextEditingController ?? widget.controller!;

@override
void initState() {
super.initState();
if (widget.controller == null) {
_internalTextEditingController = TextEditingController(text: widget.value);
_internalTextEditingController =
TextEditingController(text: widget.value);
}
}

@override
void didUpdateWidget(covariant ImpaktfullInputField oldWidget) {
super.didUpdateWidget(oldWidget);
if (widget.value != oldWidget.value && widget.value != _textEditingController.text) {
if (widget.value != oldWidget.value &&
widget.value != _textEditingController.text) {
_textEditingController.text = widget.value;
setState(() {});
}
Expand All @@ -73,7 +76,8 @@ class _ImpaktfullInputFieldState extends State<ImpaktfullInputField> {
Container(
decoration: BoxDecoration(
color: theme.colors.card,
borderRadius: BorderRadius.circular(theme.dimens.generalBorderRadius),
borderRadius:
BorderRadius.circular(theme.dimens.generalBorderRadius),
),
padding: const EdgeInsets.symmetric(
horizontal: 16,
Expand Down
6 changes: 5 additions & 1 deletion lib/src/components/screen/impaktfull_screen.dart
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,11 @@ class ImpaktfullScreen extends StatelessWidget {
@override
Widget build(BuildContext context) {
final theme = ImpaktfullTheme.of(context);
final hasNavBar = title != null || subtitle != null || actions.isNotEmpty || onBackTapped != null || bottomNavBarChild != null;
final hasNavBar = title != null ||
subtitle != null ||
actions.isNotEmpty ||
onBackTapped != null ||
bottomNavBarChild != null;
return ImpaktfullStatusBar.custom(
isDark: theme.useDarkStatusBar(
context,
Expand Down

0 comments on commit 9945365

Please sign in to comment.