Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 5 additions & 0 deletions assets/images/ic_no_tag.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
1 change: 1 addition & 0 deletions core/lib/presentation/resources/image_paths.dart
Original file line number Diff line number Diff line change
Expand Up @@ -279,6 +279,7 @@ class ImagePaths {
String get icLabel => _getImagePath('ic_label.svg');
String get icColorPicker => _getImagePath('ic_color_picker.svg');
String get icThumbsUp => _getImagePath('ic_thumbs_up.svg');
String get icNoTag => _getImagePath('ic_no_tag.svg');

String _getImagePath(String imageName) {
return AssetsPaths.images + imageName;
Expand Down
6 changes: 4 additions & 2 deletions core/lib/presentation/views/dialog/confirm_dialog_button.dart
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@ class ConfirmDialogButton extends StatelessWidget {
final double? radius;
final EdgeInsetsGeometry? padding;
final VoidCallback? onTapAction;
final Widget? child;

const ConfirmDialogButton({
super.key,
Expand All @@ -28,6 +29,7 @@ class ConfirmDialogButton extends StatelessWidget {
this.textStyle,
this.radius,
this.padding,
this.child,
this.onTapAction,
});

Expand All @@ -50,7 +52,7 @@ class ConfirmDialogButton extends StatelessWidget {
padding: padding ?? const EdgeInsets.symmetric(horizontal: 10),
),
onPressed: onTapAction,
child: icon == null
child: child ?? (icon == null
? Text(
label,
style: textStyle ?? ThemeUtils.textStyleM3LabelLarge(color: textColor),
Expand Down Expand Up @@ -79,7 +81,7 @@ class ConfirmDialogButton extends StatelessWidget {
),
),
],
),
)),
);
}
}
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
import 'package:core/presentation/extensions/color_extension.dart';
import 'package:core/presentation/views/dialog/confirm_dialog_button.dart';
import 'package:core/presentation/views/loading/cupertino_loading_widget.dart';
import 'package:flutter/material.dart';

class ModalListActionButtonWidget extends StatelessWidget {
Expand All @@ -11,6 +12,7 @@ class ModalListActionButtonWidget extends StatelessWidget {
final VoidCallback onPositiveAction;
final EdgeInsetsGeometry? padding;
final bool isPositiveActionEnabled;
final bool isProgressing;

const ModalListActionButtonWidget({
super.key,
Expand All @@ -19,6 +21,7 @@ class ModalListActionButtonWidget extends StatelessWidget {
required this.onPositiveAction,
required this.onNegativeAction,
this.isPositiveActionEnabled = true,
this.isProgressing = false,
this.padding,
this.positiveKey,
this.negativeKey,
Expand Down Expand Up @@ -52,12 +55,25 @@ class ModalListActionButtonWidget extends StatelessWidget {
),
);

Widget progressingButton = const SizedBox(
height: 48,
width: 153,
child: ConfirmDialogButton(
label: '',
padding: EdgeInsets.zero,
backgroundColor: AppColor.primaryMain,
child: CupertinoLoadingWidget(color: Colors.white),
),
);

Widget bodyWidget = Row(
mainAxisAlignment: MainAxisAlignment.end,
children: [
Flexible(child: negativeButton),
const SizedBox(width: 8),
Flexible(child: positiveButton),
Flexible(
child: isProgressing ? progressingButton : positiveButton,
),
],
);

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,13 +8,15 @@ class CupertinoLoadingWidget extends StatelessWidget {
final EdgeInsetsGeometry? padding;
final bool isCenter;
final String? semanticLabel;
final Color? color;

const CupertinoLoadingWidget({
super.key,
this.size,
this.padding,
this.isCenter = true,
this.semanticLabel,
this.color,
});

@override
Expand All @@ -24,8 +26,8 @@ class CupertinoLoadingWidget extends StatelessWidget {
child: SizedBox(
width: size ?? CupertinoLoadingWidgetStyles.size,
height: size ?? CupertinoLoadingWidgetStyles.size,
child: const CupertinoActivityIndicator(
color: CupertinoLoadingWidgetStyles.progressColor
child: CupertinoActivityIndicator(
color: color ?? CupertinoLoadingWidgetStyles.progressColor
)
)
)
Expand All @@ -34,8 +36,8 @@ class CupertinoLoadingWidget extends StatelessWidget {
child: SizedBox(
width: size ?? CupertinoLoadingWidgetStyles.size,
height: size ?? CupertinoLoadingWidgetStyles.size,
child: const CupertinoActivityIndicator(
color: CupertinoLoadingWidgetStyles.progressColor
child: CupertinoActivityIndicator(
color: color ?? CupertinoLoadingWidgetStyles.progressColor
)
),
);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -79,6 +79,7 @@ extension HandleLabelActionTypeExtension on LabelController {
required Label selectedLabel,
required Label newLabel,
}) {
popBack();
log('LabelController::editLabel:selectedLabel: $selectedLabel, newLabel: $newLabel');
if (accountId == null) {
consumeState(
Expand Down
27 changes: 15 additions & 12 deletions lib/features/labels/presentation/label_controller.dart
Original file line number Diff line number Diff line change
Expand Up @@ -84,15 +84,8 @@ class LabelController extends BaseController with LabelContextMenuMixin {
: ExpandMode.COLLAPSE;
}

Future<void> openCreateNewLabelModal(AccountId? accountId) async {
if (accountId == null) {
consumeState(
Stream.value(Left(CreateNewLabelFailure(NotFoundAccountIdException()))),
);
return;
}

await DialogRouter().openDialogModal(
Future<Label?> openCreateNewLabelModal(AccountId? accountId) async {
return await DialogRouter().openDialogModal(
child: CreateNewLabelModal(
labels: labels,
onLabelActionCallback: (label) => _createNewLabel(accountId, label),
Expand All @@ -101,24 +94,34 @@ class LabelController extends BaseController with LabelContextMenuMixin {
);
}

void _createNewLabel(AccountId accountId, Label label) {
void _createNewLabel(AccountId? accountId, Label label) {
log('LabelController::_createNewLabel:Label: $label');
if (accountId == null) {
consumeState(
Stream.value(Left(CreateNewLabelFailure(NotFoundAccountIdException()))),
);
return;
}

if (_createNewLabelInteractor == null) {
consumeState(
Stream.value(Left(CreateNewLabelFailure(InteractorNotInitialized()))),
);
} else {
consumeState(_createNewLabelInteractor!.execute(accountId, label));
return;
}

consumeState(_createNewLabelInteractor!.execute(accountId, label));
}

void _handleCreateNewLabelSuccess(CreateNewLabelSuccess success) {
toastManager.showMessageSuccess(success);
_addLabelToList(success.newLabel);
popBack(result: success.newLabel);
}

void _handleCreateNewLabelFailure(CreateNewLabelFailure failure) {
toastManager.showMessageFailure(failure);
popBack();
}

void _addLabelToList(Label newLabel) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,7 @@ mixin AddListLabelsToListEmailsMixin on EmitStateMixin {
required List<PresentationEmail> selectedEmails,
required ImagePaths imagePaths,
required VoidCallback onCallBackAction,
required OnCreateALabelAction onCreateALabelAction,
}) async {
await DialogRouter().openDialogModal(
child: ChooseLabelModal(
Expand All @@ -62,6 +63,7 @@ mixin AddListLabelsToListEmailsMixin on EmitStateMixin {
);
},
imagePaths: imagePaths,
onCreateALabelAction: onCreateALabelAction,
),
dialogLabel: 'choose-label-modal',
);
Expand Down
Loading
Loading