From cc874da012e2fe6a7798345d194ff296ae791a4d Mon Sep 17 00:00:00 2001 From: iampawan Date: Mon, 22 May 2023 16:09:39 +0530 Subject: [PATCH] Fixed #165 --- example/lib/new/demo_list.dart | 8 +++--- example/lib/new/test.dart | 0 lib/src/flutter/dialog.dart | 45 ++++++++++++++++++++++------------ 3 files changed, 34 insertions(+), 19 deletions(-) create mode 100644 example/lib/new/test.dart diff --git a/example/lib/new/demo_list.dart b/example/lib/new/demo_list.dart index 1f693ea..5a37afb 100644 --- a/example/lib/new/demo_list.dart +++ b/example/lib/new/demo_list.dart @@ -85,8 +85,6 @@ class _DemoListState extends State { showSingleIcon: false, ), body: VStack([ - FilledButton(onPressed: () {}, child: "Hi there".text.make()) - .p16(), ExpansionTile( title: "VxFilter".text.make(), childrenPadding: Vx.m32, @@ -288,6 +286,7 @@ class _DemoListState extends State { content: 'Welcome to VxDialog', title: 'Hello Alert', showClose: true, + actionTextColor: Colors.red, onPressed: () { VxToast.show(context, msg: 'Alert toast'); }, @@ -320,7 +319,8 @@ class _DemoListState extends State { title: 'Ticker Dialog', secondsToAction: 5, barrierDismissible: false, - onConfirmPress: () { + action: "Do something", + onActionPress: () { VxToast.show(context, msg: 'Confirmed'); }, ); @@ -377,7 +377,7 @@ class _DemoListState extends State { cancelBgColor: Colors.red, cancelTextColor: Colors.white, confirmBgColor: Colors.blue, - confirmTextColor: Colors.red, + confirmTextColor: Colors.white, onCancelPress: () { VxToast.show(context, msg: 'Cancelled'); }, diff --git a/example/lib/new/test.dart b/example/lib/new/test.dart new file mode 100644 index 0000000..e69de29 diff --git a/lib/src/flutter/dialog.dart b/lib/src/flutter/dialog.dart index 66a471e..908a313 100644 --- a/lib/src/flutter/dialog.dart +++ b/lib/src/flutter/dialog.dart @@ -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; } @@ -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, @@ -42,6 +46,7 @@ mixin VxDialog { cancel: confirm, cancelBgColor: confirmBgColor, cancelOnPress: onPressed, + cancelTextColor: actionTextColor, ), shape: RoundedRectangleBorder(borderRadius: _borderRadius), ), @@ -82,6 +87,8 @@ mixin VxDialog { confirmBgColor: confirmBgColor, cancelOnPress: onCancelPress, confirmOnPress: onConfirmPress, + confirmTextColor: confirmTextColor, + cancelTextColor: cancelTextColor, ), shape: RoundedRectangleBorder(borderRadius: _borderRadius), ), @@ -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( @@ -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), @@ -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; @@ -160,6 +170,8 @@ class _VxDialog extends StatelessWidget { this.confirmBgColor, this.cancelOnPress, this.confirmOnPress, + this.confirmTextColor, + this.cancelTextColor, this.second, }); @@ -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), ); } @@ -218,6 +230,7 @@ class _VxDialog extends StatelessWidget { second: second, bgColor: cancelBgColor, button: cancel, + textColor: cancelTextColor, tap: () => onCancel(context), ); } @@ -234,7 +247,7 @@ class _VxDialog extends StatelessWidget { ), ), alignment: Alignment.center, - child: getView(cancel), + child: getView(cancel, cancelTextColor), ), ); } @@ -251,7 +264,7 @@ class _VxDialog extends StatelessWidget { ), height: 42, alignment: Alignment.center, - child: getView(cancel), + child: getView(cancel, cancelTextColor), ), ), )); @@ -270,7 +283,7 @@ class _VxDialog extends StatelessWidget { ), alignment: Alignment.center, height: 42, - child: getView(confirm), + child: getView(confirm, confirmTextColor), ), ), )); @@ -304,6 +317,7 @@ class _VxDialog extends StatelessWidget { class VxTimerButton extends StatefulWidget { final int? second; final Color? bgColor; + final Color? textColor; final dynamic button; final VoidCallback? tap; @@ -311,6 +325,7 @@ class VxTimerButton extends StatefulWidget { super.key, this.second, this.bgColor, + this.textColor, this.button, this.tap, }); @@ -356,7 +371,7 @@ class VxTimerButtonState extends State { ), ), alignment: Alignment.center, - child: getView(buttonValue), + child: getView(buttonValue, widget.textColor), ); if (tempSecond! > 0) {