Explorar el Código

bersih2 MaterialStateProperty

Yulian hace 2 meses
padre
commit
a5fab5f975

+ 4 - 4
lib/src/layouts/auth/change_code.dart

@@ -120,8 +120,8 @@ class _ChangeCodePageState extends State<ChangeCodePage> {
                             height: 30, width: 100,
                             child: TextButton(
                               style: ButtonStyle(
-                                  backgroundColor: MaterialStateProperty.all<Color>(Colors.black12),
-                                  shape: MaterialStateProperty.all<RoundedRectangleBorder>(RoundedRectangleBorder(borderRadius: BorderRadius.circular(30)))
+                                  backgroundColor: WidgetStateProperty.all<Color>(Colors.black12),
+                                  shape: WidgetStateProperty.all<RoundedRectangleBorder>(RoundedRectangleBorder(borderRadius: BorderRadius.circular(30)))
                               ),
                               child: Text('textCancel'.tr(), style: TextStyle(color: Colors.black, fontSize: 12)),
                               onPressed: (){
@@ -141,8 +141,8 @@ class _ChangeCodePageState extends State<ChangeCodePage> {
                             height: 30, width: 100,
                             child: TextButton(
                               style: ButtonStyle(
-                                  backgroundColor: MaterialStateProperty.all<Color>(Color(0xff0D497F)),
-                                  shape: MaterialStateProperty.all<RoundedRectangleBorder>(RoundedRectangleBorder(borderRadius: BorderRadius.circular(30)))
+                                  backgroundColor: WidgetStateProperty.all<Color>(Color(0xff0D497F)),
+                                  shape: WidgetStateProperty.all<RoundedRectangleBorder>(RoundedRectangleBorder(borderRadius: BorderRadius.circular(30)))
                               ),
                               child: Text('textContinue'.tr(), style: TextStyle(color: Colors.white, fontSize: 12)),
                               onPressed: ()async{

+ 13 - 15
lib/src/layouts/components/photo_chat.dart

@@ -19,19 +19,18 @@ class PhotoChat extends StatefulWidget {
   final bool? isBroadcast;
   final Uint8List? image;
 
-  PhotoChat(this.data, this.media, this.isBroadcast, this.image);
+  const PhotoChat(this.data, this.media, this.isBroadcast, this.image, {super.key});
 
   @override
-  _PhotoChatState createState() => _PhotoChatState();
+  PhotoChatState createState() => PhotoChatState();
 }
 
-class _PhotoChatState extends State<PhotoChat> {
+class PhotoChatState extends State<PhotoChat> {
   final ApiAuthProvider apiAuthProvider = ApiAuthProvider();
-  TextEditingController controllerPesan = new TextEditingController();
+  TextEditingController controllerPesan = TextEditingController();
   Uint8List? image;
 
   Future getImage() async {
-//    print('photochat in');
     XFile? pickedFile;
     if(widget.media == ImageSource.camera){
       await availableCameras().then((camera) => Navigator.push(context, PageTransition(type: PageTransitionType.rightToLeft, child: OpenCamera(cameras: camera))).then((value) async{
@@ -45,12 +44,12 @@ class _PhotoChatState extends State<PhotoChat> {
     }
 
     if (pickedFile != null) {
-      var imagess = img.decodeImage(await pickedFile!.readAsBytes());
-      var imgPercent = (1000 / (imagess!.width / 100)).toDouble();
-      if (imagess.width > 1000) {
-        imagess = img.copyResize(imagess, width: ((imagess.width / 100) * imgPercent).toInt(), height: ((imagess.height / 100) * imgPercent).toInt());
+      var images = img.decodeImage(await pickedFile!.readAsBytes());
+      var imgPercent = (1000 / (images!.width / 100)).toDouble();
+      if (images.width > 1000) {
+        images = img.copyResize(images, width: ((images.width / 100) * imgPercent).toInt(), height: ((images.height / 100) * imgPercent).toInt());
       }
-      var compressed = img.encodeJpg(imagess, quality: 60);
+      var compressed = img.encodeJpg(images, quality: 60);
       setState(() => image = compressed);
     } else {
       Navigator.of(context).pop(null);
@@ -97,7 +96,6 @@ class _PhotoChatState extends State<PhotoChat> {
               Container(
                 alignment: Alignment.bottomCenter,
                 child: Container(
-//              width: double.infinity,
                   padding: const EdgeInsets.all(10),
                   color: Colors.black54,
                   child: Row(
@@ -129,12 +127,12 @@ class _PhotoChatState extends State<PhotoChat> {
                             height: 50,
                             child: ElevatedButton(
                               style: ButtonStyle(
-                                backgroundColor: MaterialStateProperty.all<Color>(primaryColor),
-                                shape: MaterialStateProperty.all<RoundedRectangleBorder>(RoundedRectangleBorder(
+                                backgroundColor: WidgetStateProperty.all<Color>(primaryColor),
+                                shape: WidgetStateProperty.all<RoundedRectangleBorder>(RoundedRectangleBorder(
                                   borderRadius: BorderRadius.circular(50),
                                 )),
-                                elevation: MaterialStateProperty.all(2),
-                                padding: MaterialStateProperty.all(const EdgeInsets.only(left: 1)),
+                                elevation: WidgetStateProperty.all(2),
+                                padding: WidgetStateProperty.all(const EdgeInsets.only(left: 1)),
                               ),
                               child: Image.asset('assets/image/icon/Send.png', width: 25, height: 25),
                               onPressed: () async {

+ 7 - 7
lib/src/layouts/components/template.dart

@@ -47,10 +47,10 @@ Widget buttonTemplate({double width = double.infinity, double height = 51, requi
     height: height,
     child: ElevatedButton(
       style: ButtonStyle(
-          elevation: MaterialStateProperty.all<double>(0),
-          backgroundColor: MaterialStateProperty.all<Color>(backgroundColor),
-          shape: MaterialStateProperty.all<RoundedRectangleBorder>(RoundedRectangleBorder(borderRadius: BorderRadius.circular(12))),
-          side: MaterialStateProperty.all<BorderSide>(BorderSide(color: borderColor))
+          elevation: WidgetStateProperty.all<double>(0),
+          backgroundColor: WidgetStateProperty.all<Color>(backgroundColor),
+          shape: WidgetStateProperty.all<RoundedRectangleBorder>(RoundedRectangleBorder(borderRadius: BorderRadius.circular(12))),
+          side: WidgetStateProperty.all<BorderSide>(BorderSide(color: borderColor))
       ),
       onPressed: ()=>action(),
       child: Text(text, style: TextStyle(fontSize: 16, color: textColor, fontWeight: FontWeight.w500)),
@@ -694,8 +694,8 @@ handlingError(context, type) {
                     child: TextButton(
                       style: ButtonStyle(
                           backgroundColor:
-                          MaterialStateProperty.all<Color>(primaryColor),
-                          shape: MaterialStateProperty.all<
+                          WidgetStateProperty.all<Color>(primaryColor),
+                          shape: WidgetStateProperty.all<
                               RoundedRectangleBorder>(
                               RoundedRectangleBorder(
                                 borderRadius: BorderRadius.circular(5),
@@ -750,7 +750,7 @@ handlingError(context, type) {
 class NoImageFound extends StatelessWidget {
   bool show = true;
 
-  NoImageFound(this.show);
+  NoImageFound(this.show, {super.key});
 
   @override
   Widget build(BuildContext context) {

+ 2 - 2
lib/src/layouts/web/request_select.dart

@@ -87,7 +87,7 @@ class _WebReqSelectPageState extends State<WebReqSelectPage> {
                 SizedBox(
                   height: 40, width: 100,
                   child: ElevatedButton(
-                    style: ButtonStyle(elevation: MaterialStateProperty.all<double>(0), backgroundColor: MaterialStateProperty.all<Color>(primaryColor), shape: MaterialStateProperty.all<RoundedRectangleBorder>(RoundedRectangleBorder(borderRadius: BorderRadius.circular(50))), side: MaterialStateProperty.all<BorderSide>(BorderSide(color: primaryColor))),
+                    style: ButtonStyle(elevation: WidgetStateProperty.all<double>(0), backgroundColor: WidgetStateProperty.all<Color>(primaryColor), shape: WidgetStateProperty.all<RoundedRectangleBorder>(RoundedRectangleBorder(borderRadius: BorderRadius.circular(50))), side: WidgetStateProperty.all<BorderSide>(BorderSide(color: primaryColor))),
                     onPressed: ()=>reqFunc.getData(context, searchController.text.trim()==''?null:searchController.text.trim(), widget),
                     child: Text('searchButton'.tr(), style: TextStyle(fontSize: 14, color: Colors.white, fontWeight: FontWeight.w600)),
                   ),
@@ -138,6 +138,7 @@ class _WebReqSelectPageState extends State<WebReqSelectPage> {
                             constraints: BoxConstraints(minWidth: minWidth, minHeight: minHeight),
                             child: Container(
                               width: size, height: size*1.4,
+                              decoration: BoxDecoration(color: Colors.white, border: Border.all(color: textColor.withValues(alpha: 0.15)), borderRadius: BorderRadius.all(Radius.circular(12))),
                               child: Column(
                                 crossAxisAlignment: CrossAxisAlignment.start,
                                 children: [
@@ -156,7 +157,6 @@ class _WebReqSelectPageState extends State<WebReqSelectPage> {
                                   )
                                 ],
                               ),
-                              decoration: BoxDecoration(color: Colors.white, border: Border.all(color: textColor.withValues(alpha: 0.15)), borderRadius: BorderRadius.all(Radius.circular(12))),
                             ),
                           ),
                           onTap: ()=>navigateTo(context, WebReqCreatePage(user: widget.user, request: Provider.of<RequestModule>(context, listen: false).data()[i], fromSearch: true)),

+ 7 - 15
lib/src/utils/dio_logging_interceptors.dart

@@ -1,4 +1,5 @@
 import 'package:dio/dio.dart';
+import 'package:flutter/cupertino.dart';
 import 'package:telnow_mobile_new/src/injector/injector.dart';
 import 'package:telnow_mobile_new/src/model/refreshtoken/refresh_token_body.dart';
 import 'package:telnow_mobile_new/src/model/token/token.dart';
@@ -32,31 +33,22 @@ class DioLoggingInterceptors extends InterceptorsWrapper {
   }
 
   @override
-  void onError(DioError dioError, ErrorInterceptorHandler handler) async {
-    // print(dioError.response?.data.toString());
-    // print(dioError.response?.realUri.toString());
+  void onError(DioException err, ErrorInterceptorHandler handler) async {
     try {
-      if (dioError.response?.statusCode == 401) {
-        // print("auth error");
+      if (err.response?.statusCode == 401) {
         bool? checkRefreshCount = _sharedPreferencesManager.isKeyExists(SharedPreferencesManager.keyCountRefreshToken);
         int? refreshCount = _sharedPreferencesManager.getInt(SharedPreferencesManager.keyCountRefreshToken);
         if(checkRefreshCount! && refreshCount! > 2){
-          // handlingError(NavigationService.navigatorKey.currentContext, 3);
           eventBus.fire("logout");
           return;
         }
 
-        // if (dioError.response!.data.toString().contains("Invalid refresh token")) {
-        //   handlingError(NavigationService.navigatorKey.currentContext, 3);
-        // }
-        if (dioError.response!.data.toString().contains("Access token expired")) {
-          // print("token expired");
-
+        if (err.response!.data.toString().contains("Access token expired")) {
           String? refreshToken = _sharedPreferencesManager.getString(SharedPreferencesManager.keyRefreshToken)!;
           RefreshTokenBody? refreshTokenBody = RefreshTokenBody('refresh_token', refreshToken);
           Token? token = await U.refreshAuth(refreshTokenBody);
           if (token != null) {
-            RequestOptions? options = dioError.response?.requestOptions;
+            RequestOptions? options = err.response?.requestOptions;
             options?.headers.addAll({'requirestoken': true});
             try {
               var r = await _dio.fetch(options!);
@@ -64,7 +56,7 @@ class DioLoggingInterceptors extends InterceptorsWrapper {
               await _sharedPreferencesManager.putInt(SharedPreferencesManager.keyCountRefreshToken, 0);
               return;
             } catch (error2) {
-              print(error2);
+              debugPrint(error2.toString());
             }
           }
         }
@@ -75,6 +67,6 @@ class DioLoggingInterceptors extends InterceptorsWrapper {
       eventBus.fire("logout");
       // handlingError(NavigationService.navigatorKey.currentContext, 3);
     }
-    super.onError(dioError, handler);
+    super.onError(err, handler);
   }
 }