-
Notifications
You must be signed in to change notification settings - Fork 42
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
9 changed files
with
329 additions
and
1 deletion.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,20 @@ | ||
import 'package:flutter/material.dart'; | ||
|
||
class MyCloseButton extends StatelessWidget { | ||
const MyCloseButton({super.key, required this.onPressed}); | ||
final void Function() onPressed; | ||
@override | ||
Widget build(BuildContext context) { | ||
return IconButton( | ||
icon: Container( | ||
decoration: const BoxDecoration( | ||
shape: BoxShape.circle, | ||
color: Colors.grey, | ||
), | ||
child: const Icon(Icons.close, size: 20)), //24 | ||
padding: EdgeInsets.zero, // Không có padding | ||
constraints: const BoxConstraints(), // Loại bỏ các ràng buộc mặc định | ||
onPressed: onPressed, | ||
); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,35 @@ | ||
import 'package:flutter/material.dart'; | ||
|
||
// ignore: must_be_immutable | ||
class MyElevatedButton extends StatelessWidget { | ||
const MyElevatedButton( | ||
{super.key, | ||
required this.onPressed, | ||
required this.buttonName, | ||
this.textColor, | ||
this.backgroundColor, | ||
this.width, | ||
this.height}); | ||
final String buttonName; | ||
final Function()? onPressed; | ||
final Color? textColor; | ||
final Color? backgroundColor; | ||
final double? width; | ||
final double? height; | ||
@override | ||
Widget build(BuildContext context) { | ||
return ElevatedButton( | ||
style: ButtonStyle( | ||
// fixedSize:MaterialStatePropertyAll(Size(width??,height)), | ||
// textStyle: MaterialStatePropertyAll( | ||
// GoogleFonts.sarabun( | ||
// color: textColor, fontWeight: FontWeight.bold, fontSize: 12) | ||
// ), | ||
elevation: WidgetStateProperty.all(6), | ||
backgroundColor: | ||
WidgetStatePropertyAll(backgroundColor ?? Colors.transparent), | ||
), | ||
onPressed: onPressed, | ||
child: Text(buttonName)); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,28 @@ | ||
import 'package:flutter/cupertino.dart'; | ||
import '../../config/routes/navigator.dart'; | ||
import '../../main.dart'; | ||
|
||
class LoadingDialog { | ||
static showLoading({BuildContext? context}) { | ||
showCupertinoDialog( | ||
context: globalAppContext ?? context!, | ||
builder: (context) { | ||
return const CupertinoAlertDialog( | ||
content: LoadingState(), | ||
); | ||
}); | ||
} | ||
|
||
static hideLoading() { | ||
pop(); | ||
} | ||
} | ||
|
||
class LoadingState extends StatelessWidget { | ||
const LoadingState({super.key}); | ||
|
||
@override | ||
Widget build(BuildContext context) { | ||
return const CupertinoActivityIndicator(); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,66 @@ | ||
import 'package:flutter/cupertino.dart'; | ||
import 'package:flutter/material.dart'; | ||
import '../../../config/routes/navigator.dart'; | ||
import '../../../main.dart'; | ||
|
||
class MessageDialog { | ||
static void showMessageDialog({ | ||
Widget? contentWidget, | ||
String? contentText, | ||
String? closeText = 'Close', | ||
List<Widget>? actions, | ||
bool tapOutsideToClose = false, | ||
Color? color, | ||
Widget? titleWidget, | ||
String? titleText, | ||
Function()? onTapClose, | ||
}) { | ||
showCupertinoModalPopup<void>( | ||
context: globalAppContext!, | ||
barrierDismissible: tapOutsideToClose, | ||
builder: (BuildContext context) { | ||
return CupertinoAlertDialog( | ||
title: titleWidget ?? | ||
Text( | ||
titleText ?? '', | ||
style: const TextStyle( | ||
color: Colors.blue, fontWeight: FontWeight.bold), | ||
), | ||
content: Material( | ||
color: Colors.transparent, | ||
child: contentWidget ?? | ||
Text(contentText ?? '', | ||
textAlign: TextAlign.start, | ||
style: const TextStyle(fontSize: 16)), | ||
), | ||
actions: actions ?? | ||
[ | ||
TextButton( | ||
onPressed: onTapClose ?? | ||
() { | ||
pop(); | ||
}, | ||
child: Text(closeText ?? 'OK')) | ||
], | ||
); | ||
}, | ||
); | ||
} | ||
|
||
static void showError({ | ||
BuildContext? context, | ||
String? contentText, | ||
Widget? contentWidget, | ||
String? closeText = 'Close', | ||
List<Widget>? actions, | ||
bool tapOutsideToClose = false, | ||
}) { | ||
showMessageDialog( | ||
color: Colors.red, | ||
contentText: contentText, | ||
contentWidget: contentWidget, | ||
closeText: closeText, | ||
actions: actions, | ||
tapOutsideToClose: tapOutsideToClose); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,99 @@ | ||
import 'package:flutter/material.dart'; | ||
|
||
class TextFieldInput extends StatelessWidget { | ||
const TextFieldInput({ | ||
super.key, | ||
this.keyboardType, | ||
this.labelText, | ||
this.style, | ||
this.obscureText = false, | ||
this.autocorrect, | ||
this.onChanged, | ||
this.suffixIcon, | ||
this.suffix, | ||
this.suffixText, | ||
this.suffixStyle, | ||
this.suffixIconColor, | ||
this.suffixIconConstraints, | ||
this.filled, | ||
this.fillColor, | ||
this.readOnly = false, | ||
this.prefixIcon, | ||
this.controller, | ||
this.hintText, | ||
this.hintStyle, | ||
this.errorText, | ||
this.onFieldSubmitted, | ||
this.focusNode, | ||
// this.initText, | ||
this.minLines, | ||
this.maxLines, | ||
this.autofocus = false, | ||
}); | ||
final TextInputType? keyboardType; | ||
final String? labelText, hintText; | ||
final bool obscureText; | ||
final bool? autocorrect; | ||
final ValueChanged<String>? onChanged; | ||
final Widget? suffixIcon; | ||
final Widget? prefixIcon; | ||
final Widget? suffix; | ||
final String? suffixText; | ||
final TextStyle? suffixStyle; | ||
final Color? suffixIconColor; | ||
final BoxConstraints? suffixIconConstraints; | ||
final bool? filled; | ||
final Color? fillColor; | ||
final bool readOnly; | ||
final TextEditingController? controller; | ||
final TextStyle? hintStyle; | ||
final String? errorText; | ||
final void Function(String)? onFieldSubmitted; | ||
final FocusNode? focusNode; | ||
final int? minLines; | ||
final int? maxLines; | ||
final TextStyle? style; | ||
final bool autofocus; | ||
@override | ||
Widget build(BuildContext context) { | ||
return TextFormField( | ||
autofocus: autofocus, | ||
onChanged: onChanged, | ||
style: style ?? (readOnly ? const TextStyle(color: Colors.grey) : null), | ||
maxLines: maxLines, | ||
minLines: minLines, | ||
focusNode: focusNode, | ||
onFieldSubmitted: onFieldSubmitted, | ||
obscureText: obscureText, | ||
controller: controller, | ||
keyboardType: keyboardType, | ||
readOnly: readOnly, | ||
cursorColor: Colors.black, | ||
decoration: InputDecoration( | ||
errorText: errorText, | ||
hintText: hintText, | ||
counterStyle: const TextStyle(color: Colors.pink), | ||
labelStyle: const TextStyle(color: Colors.black), | ||
hintStyle: hintStyle ?? const TextStyle(color: Colors.grey), | ||
prefixIcon: prefixIcon, | ||
suffixIcon: suffixIcon, | ||
suffix: suffix, | ||
contentPadding: | ||
const EdgeInsets.symmetric(vertical: 10, horizontal: 15), | ||
labelText: labelText, | ||
enabledBorder: const OutlineInputBorder( | ||
borderSide: BorderSide(color: Colors.grey)), | ||
focusColor: Colors.black, | ||
focusedBorder: const OutlineInputBorder( | ||
borderSide: BorderSide(color: Colors.black)), | ||
border: const OutlineInputBorder( | ||
borderSide: BorderSide(color: Colors.grey)), | ||
filled: filled ?? true, | ||
fillColor: readOnly | ||
? (fillColor ?? Colors.grey) | ||
: fillColor ?? | ||
Colors.white, | ||
), | ||
); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,16 @@ | ||
import 'package:flutter/material.dart'; | ||
|
||
import '../../main.dart'; | ||
|
||
push(Widget page) { | ||
return navigatorKey.currentState | ||
?.push(MaterialPageRoute(builder: (context) => page)); | ||
} | ||
pushReplacement(Widget page) { | ||
return navigatorKey.currentState | ||
?.pushReplacement(MaterialPageRoute(builder: (context) => page)); | ||
} | ||
|
||
pop({dynamic arguments}) { | ||
navigatorKey.currentState?.pop(arguments ?? {}); | ||
} |
Empty file.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,63 @@ | ||
import 'package:flutter/material.dart'; | ||
|
||
class MyTextStyle { | ||
static Text errorText(String text) { | ||
return Text(text, | ||
style: const TextStyle( | ||
color: Colors.red, fontSize: 18, fontWeight: FontWeight.bold)); | ||
} | ||
|
||
Text noElement(String text) { | ||
return Text( | ||
text, | ||
style: const TextStyle( | ||
color: Colors.grey, fontSize: 18, fontWeight: FontWeight.bold), | ||
); | ||
} | ||
|
||
static const translate = | ||
TextStyle(fontSize: 16, color: Colors.amber, fontStyle: FontStyle.italic); | ||
static const greySemiBold = TextStyle( | ||
color: Color.fromRGBO(179, 179, 179, 100), | ||
fontWeight: FontWeight.w600, | ||
fontSize: 14, //11, | ||
); | ||
|
||
static const titleAppbar = TextStyle( | ||
fontWeight: FontWeight.w600, | ||
fontSize: 18, | ||
); | ||
|
||
// static const inboxTextBlack = TextStyle( | ||
// color: Colors.black, | ||
// fontWeight: FontWeight.w500, //medium | ||
// fontSize: 12, | ||
// ); | ||
// static const inboxTextWhite = TextStyle( | ||
// color: Colors.white.withOpacity(1), | ||
// fontWeight: FontWeight.w400, //medium | ||
// fontSize: 16, | ||
// ); | ||
static const heading1 = TextStyle( | ||
fontWeight: FontWeight.bold, | ||
fontSize: 16, | ||
); | ||
|
||
static const heading2 = TextStyle( | ||
fontWeight: FontWeight.w400, | ||
fontSize: 14, | ||
); | ||
static const textSelected = TextStyle( | ||
fontWeight: FontWeight.w400, | ||
fontSize: 14, | ||
height: 1.2, | ||
backgroundColor: Colors.brown, //AppColor.backgroundText, | ||
decoration: TextDecoration.none, | ||
); | ||
static const normal = TextStyle( | ||
fontWeight: FontWeight.w400, | ||
fontSize: 14, | ||
height: 1.2, | ||
decoration: TextDecoration.none, | ||
); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters