|
@@ -0,0 +1,201 @@
|
|
|
+import 'package:flutter/material.dart';
|
|
|
+import 'package:flutter/services.dart';
|
|
|
+import 'package:flutter_screenutil/flutter_screenutil.dart';
|
|
|
+import 'package:fluttertoast/fluttertoast.dart';
|
|
|
+import 'package:smartledz_wifi_test/widgets/animations/animation_for_rotation.dart';
|
|
|
+
|
|
|
+class Modal {
|
|
|
+
|
|
|
+
|
|
|
+ static Widget buildTitle({
|
|
|
+ required String title,
|
|
|
+ double? size,
|
|
|
+ }){
|
|
|
+ return Padding(
|
|
|
+ padding: EdgeInsets.only(bottom: 5.sp),
|
|
|
+ child: Center(
|
|
|
+ child: Text(
|
|
|
+ title,
|
|
|
+ style: TextStyle(
|
|
|
+ fontWeight: FontWeight.bold,
|
|
|
+ fontSize: size ?? 15.sp,
|
|
|
+ color: Colors.black,
|
|
|
+ )
|
|
|
+ ),
|
|
|
+ ),
|
|
|
+ );
|
|
|
+ }
|
|
|
+
|
|
|
+
|
|
|
+ static Widget buildContent({
|
|
|
+ required String content,
|
|
|
+ TextAlign? textAlign,
|
|
|
+ }){
|
|
|
+ return Text(
|
|
|
+ content,
|
|
|
+ textAlign: textAlign,
|
|
|
+ style: TextStyle(
|
|
|
+ fontSize: 15.sp,
|
|
|
+ color: const Color(0xAA000000)
|
|
|
+ )
|
|
|
+ );
|
|
|
+ }
|
|
|
+
|
|
|
+
|
|
|
+ static Widget buildInputForBorder({
|
|
|
+ String? initValue,
|
|
|
+ String? hintText,
|
|
|
+ List<TextInputFormatter>? inputFormatters,
|
|
|
+ TextEditingController? controller,
|
|
|
+ void Function(String)? onChanged,
|
|
|
+ }){
|
|
|
+ return Container(
|
|
|
+ height: 40.sp,
|
|
|
+ margin: EdgeInsets.symmetric(vertical: 15.sp),
|
|
|
+ decoration: BoxDecoration(
|
|
|
+ border: Border.all(
|
|
|
+ color: const Color(0xAA000000),
|
|
|
+ width: .5
|
|
|
+ )
|
|
|
+ ),
|
|
|
+ child: TextFormField(
|
|
|
+ controller: controller,
|
|
|
+ initialValue: initValue,
|
|
|
+ onChanged: onChanged,
|
|
|
+ cursorColor: const Color(0xFF00AAFF),
|
|
|
+ decoration: InputDecoration(
|
|
|
+ hintText: hintText,
|
|
|
+ hintStyle: TextStyle(
|
|
|
+ fontSize: 15.sp,
|
|
|
+ color: Colors.grey.shade500
|
|
|
+ ),
|
|
|
+ border: const OutlineInputBorder(borderSide: BorderSide.none),
|
|
|
+ contentPadding: EdgeInsets.symmetric(horizontal: 10.sp)
|
|
|
+ ),
|
|
|
+ inputFormatters: inputFormatters,
|
|
|
+ style: TextStyle(fontSize: 15.sp),
|
|
|
+ ),
|
|
|
+ );
|
|
|
+ }
|
|
|
+
|
|
|
+
|
|
|
+ static Widget buildButtonForTwo({
|
|
|
+ required String leftBtnTitle,
|
|
|
+ required String rightBtnTitle,
|
|
|
+ void Function()? onLeftBtnTap,
|
|
|
+ void Function()? onRightBtnTap,
|
|
|
+ }){
|
|
|
+ return Row(
|
|
|
+ children: [
|
|
|
+ GestureDetector(
|
|
|
+ onTap: onLeftBtnTap,
|
|
|
+ child: Container(
|
|
|
+ color: const Color(0xFFAAAAAA),
|
|
|
+ padding: EdgeInsets.symmetric(vertical: 8.h, horizontal: 10.w),
|
|
|
+ child: Text(leftBtnTitle, style: TextStyle(color: Colors.white, fontSize: 15.sp)),
|
|
|
+ ),
|
|
|
+ ),
|
|
|
+ Expanded(
|
|
|
+ child: Align(
|
|
|
+ alignment: Alignment.centerRight,
|
|
|
+ child: GestureDetector(
|
|
|
+ onTap: onRightBtnTap,
|
|
|
+ child: Container(
|
|
|
+ color: const Color(0xFF00AAFF),
|
|
|
+ padding: EdgeInsets.symmetric(vertical: 8.h, horizontal: 10.w),
|
|
|
+ child: Text(rightBtnTitle, style: TextStyle(color: Colors.white, fontSize: 15.sp)
|
|
|
+ ),
|
|
|
+ ),
|
|
|
+ ),
|
|
|
+ ),
|
|
|
+ )
|
|
|
+ ],
|
|
|
+ );
|
|
|
+ }
|
|
|
+
|
|
|
+
|
|
|
+ static Widget buildButtonForFull({
|
|
|
+ required String title,
|
|
|
+ void Function()? onTap,
|
|
|
+ }){
|
|
|
+ return GestureDetector(
|
|
|
+ onTap: onTap,
|
|
|
+ child: Container(
|
|
|
+ alignment: Alignment.center,
|
|
|
+ color: const Color(0xFF00AAFF),
|
|
|
+ padding: EdgeInsets.symmetric(vertical: 8.h),
|
|
|
+ child: Text(title, style: TextStyle(color: Colors.white, fontSize: 15.sp)
|
|
|
+ ),
|
|
|
+ ),
|
|
|
+ );
|
|
|
+ }
|
|
|
+
|
|
|
+
|
|
|
+ static void open({
|
|
|
+ required BuildContext context,
|
|
|
+ required Widget Function(BuildContext) builder,
|
|
|
+ double? width,
|
|
|
+ EdgeInsetsGeometry? padding,
|
|
|
+ bool disableShadeClose = false,
|
|
|
+ bool disableReturnKey = false,
|
|
|
+ }){
|
|
|
+ showDialog(
|
|
|
+ barrierDismissible: !disableShadeClose,
|
|
|
+ context: context,
|
|
|
+ builder: (BuildContext context){
|
|
|
+ Widget child = UnconstrainedBox(
|
|
|
+ child: Container(
|
|
|
+ width: width ?? 300.w,
|
|
|
+ color: Colors.white,
|
|
|
+ padding: padding ?? EdgeInsets.all(15.w),
|
|
|
+ child: builder(context),
|
|
|
+ ),
|
|
|
+ );
|
|
|
+ if(disableReturnKey == true){
|
|
|
+ return WillPopScope(child: child, onWillPop: () async => false);
|
|
|
+ }
|
|
|
+ return child;
|
|
|
+ }
|
|
|
+ );
|
|
|
+ }
|
|
|
+
|
|
|
+
|
|
|
+ static void openLoading({
|
|
|
+ required BuildContext context,
|
|
|
+ required String tip,
|
|
|
+ }){
|
|
|
+ showDialog(
|
|
|
+ barrierDismissible: false,
|
|
|
+ context: context,
|
|
|
+ builder: (BuildContext context){
|
|
|
+ return WillPopScope(
|
|
|
+ onWillPop: () async => false,
|
|
|
+ child: UnconstrainedBox(
|
|
|
+ child: Row(
|
|
|
+ children: [
|
|
|
+ AnimationForRotation(
|
|
|
+ duration: const Duration(milliseconds: 400),
|
|
|
+ child: Icon(Icons.refresh, color: const Color(0xFF00AAFF), size: 45.sp),
|
|
|
+ ),
|
|
|
+ SizedBox(width: 10.sp),
|
|
|
+ Text(tip, style: TextStyle(color: Colors.white, fontSize: 23.sp, fontWeight: FontWeight.bold))
|
|
|
+ ],
|
|
|
+ ),
|
|
|
+ ),
|
|
|
+ );
|
|
|
+ }
|
|
|
+ );
|
|
|
+ }
|
|
|
+
|
|
|
+
|
|
|
+ static void toast({
|
|
|
+ required String msg
|
|
|
+ }){
|
|
|
+ Fluttertoast.showToast(
|
|
|
+ msg: msg,
|
|
|
+ gravity: ToastGravity.TOP,
|
|
|
+ backgroundColor: const Color(0xFFEEEEEE),
|
|
|
+ textColor: const Color(0xFF00AAFF)
|
|
|
+ );
|
|
|
+ }
|
|
|
+}
|