Skip to content

Commit

Permalink
Fixed #165
Browse files Browse the repository at this point in the history
  • Loading branch information
iampawan committed May 22, 2023
1 parent 2849439 commit cc874da
Show file tree
Hide file tree
Showing 3 changed files with 34 additions and 19 deletions.
8 changes: 4 additions & 4 deletions example/lib/new/demo_list.dart
Expand Up @@ -85,8 +85,6 @@ class _DemoListState extends State<DemoList> {
showSingleIcon: false,
),
body: VStack([
FilledButton(onPressed: () {}, child: "Hi there".text.make())
.p16(),
ExpansionTile(
title: "VxFilter".text.make(),
childrenPadding: Vx.m32,
Expand Down Expand Up @@ -288,6 +286,7 @@ class _DemoListState extends State<DemoList> {
content: 'Welcome to VxDialog',
title: 'Hello Alert',
showClose: true,
actionTextColor: Colors.red,
onPressed: () {
VxToast.show(context, msg: 'Alert toast');
},
Expand Down Expand Up @@ -320,7 +319,8 @@ class _DemoListState extends State<DemoList> {
title: 'Ticker Dialog',
secondsToAction: 5,
barrierDismissible: false,
onConfirmPress: () {
action: "Do something",
onActionPress: () {
VxToast.show(context, msg: 'Confirmed');
},
);
Expand Down Expand Up @@ -377,7 +377,7 @@ class _DemoListState extends State<DemoList> {
cancelBgColor: Colors.red,
cancelTextColor: Colors.white,
confirmBgColor: Colors.blue,
confirmTextColor: Colors.red,
confirmTextColor: Colors.white,
onCancelPress: () {
VxToast.show(context, msg: 'Cancelled');
},
Expand Down
Empty file added example/lib/new/test.dart
Empty file.
45 changes: 30 additions & 15 deletions lib/src/flutter/dialog.dart
Expand Up @@ -6,9 +6,13 @@ import 'package:velocity_x/src/flutter/divider.dart';
double _circular = 5.0;
BorderRadius _borderRadius = BorderRadius.circular(_circular);

Widget getView(dynamic child) {
Widget getView(dynamic child, Color? textColor) {
if (child is String) {
return Text(child);
if (textColor == null) {
return Text(child);
} else {
return Text(child, style: TextStyle(color: textColor));
}
} else if (child is Widget) {
return child;
}
Expand All @@ -22,7 +26,7 @@ mixin VxDialog {
dynamic content,
dynamic confirm = 'OK',
Color? confirmBgColor,
Color? confirmTextColor,
Color? actionTextColor,
bool showClose = false,
VoidCallback? onPressed,
bool barrierDismissible = true,
Expand All @@ -42,6 +46,7 @@ mixin VxDialog {
cancel: confirm,
cancelBgColor: confirmBgColor,
cancelOnPress: onPressed,
cancelTextColor: actionTextColor,
),
shape: RoundedRectangleBorder(borderRadius: _borderRadius),
),
Expand Down Expand Up @@ -82,6 +87,8 @@ mixin VxDialog {
confirmBgColor: confirmBgColor,
cancelOnPress: onCancelPress,
confirmOnPress: onConfirmPress,
confirmTextColor: confirmTextColor,
cancelTextColor: cancelTextColor,
),
shape: RoundedRectangleBorder(borderRadius: _borderRadius),
),
Expand All @@ -94,11 +101,11 @@ mixin VxDialog {
String? title,
bool showClose = false,
dynamic content,
dynamic confirm = 'Confirm',
dynamic action = 'Confirm',
int secondsToAction = 3,
Color? confirmBgColor,
Color? confirmTextColor,
VoidCallback? onConfirmPress,
Color? actionBgColor,
Color? actionTextColor,
VoidCallback? onActionPress,
bool barrierDismissible = true,
}) {
showDialog(
Expand All @@ -113,9 +120,10 @@ mixin VxDialog {
title: title,
showClose: showClose,
content: content,
cancel: confirm,
cancelBgColor: confirmBgColor,
cancelOnPress: onConfirmPress,
cancel: action,
cancelBgColor: actionBgColor,
cancelOnPress: onActionPress,
cancelTextColor: actionTextColor,
second: secondsToAction,
),
shape: RoundedRectangleBorder(borderRadius: _borderRadius),
Expand Down Expand Up @@ -146,6 +154,8 @@ class _VxDialog extends StatelessWidget {
final dynamic confirm;
final Color? cancelBgColor;
final Color? confirmBgColor;
final Color? confirmTextColor;
final Color? cancelTextColor;
final VoidCallback? cancelOnPress;
final VoidCallback? confirmOnPress;
final int? second;
Expand All @@ -160,6 +170,8 @@ class _VxDialog extends StatelessWidget {
this.confirmBgColor,
this.cancelOnPress,
this.confirmOnPress,
this.confirmTextColor,
this.cancelTextColor,
this.second,
});

Expand Down Expand Up @@ -208,7 +220,7 @@ class _VxDialog extends StatelessWidget {
assert(content != null);
return Padding(
padding: const EdgeInsets.all(16),
child: getView(content),
child: getView(content, null),
);
}

Expand All @@ -218,6 +230,7 @@ class _VxDialog extends StatelessWidget {
second: second,
bgColor: cancelBgColor,
button: cancel,
textColor: cancelTextColor,
tap: () => onCancel(context),
);
}
Expand All @@ -234,7 +247,7 @@ class _VxDialog extends StatelessWidget {
),
),
alignment: Alignment.center,
child: getView(cancel),
child: getView(cancel, cancelTextColor),
),
);
}
Expand All @@ -251,7 +264,7 @@ class _VxDialog extends StatelessWidget {
),
height: 42,
alignment: Alignment.center,
child: getView(cancel),
child: getView(cancel, cancelTextColor),
),
),
));
Expand All @@ -270,7 +283,7 @@ class _VxDialog extends StatelessWidget {
),
alignment: Alignment.center,
height: 42,
child: getView(confirm),
child: getView(confirm, confirmTextColor),
),
),
));
Expand Down Expand Up @@ -304,13 +317,15 @@ class _VxDialog extends StatelessWidget {
class VxTimerButton extends StatefulWidget {
final int? second;
final Color? bgColor;
final Color? textColor;
final dynamic button;
final VoidCallback? tap;

const VxTimerButton({
super.key,
this.second,
this.bgColor,
this.textColor,
this.button,
this.tap,
});
Expand Down Expand Up @@ -356,7 +371,7 @@ class VxTimerButtonState extends State<VxTimerButton> {
),
),
alignment: Alignment.center,
child: getView(buttonValue),
child: getView(buttonValue, widget.textColor),
);

if (tempSecond! > 0) {
Expand Down

0 comments on commit cc874da

Please sign in to comment.