Merge branch 'development_mirza' into 'master'
Development mirza See merge request Cloud_Solution/mohemm-flutter-app!178merge-requests/179/merge
						commit
						6bd953af71
					
				| @ -0,0 +1,46 @@ | ||||
| import 'dart:io'; | ||||
| 
 | ||||
| import 'package:flutter/cupertino.dart'; | ||||
| import 'package:mohem_flutter_app/app_state/app_state.dart'; | ||||
| import 'package:wifi_iot/wifi_iot.dart'; | ||||
| 
 | ||||
| class HmgConnectionProvider extends ChangeNotifier { | ||||
|   bool isConnectedToHMG = false; | ||||
| 
 | ||||
|   Future<bool> checkHmgNetworkConnectivity() async { | ||||
|     if (await WiFiForIoTPlugin.getSSID() == AppState().getMohemmWifiSSID) { | ||||
|       isConnectedToHMG = true; | ||||
|     } else { | ||||
|       isConnectedToHMG = false; | ||||
|     } | ||||
|     AppState().isConnectedToHMG = isConnectedToHMG; | ||||
|     return isConnectedToHMG; | ||||
|   } | ||||
| 
 | ||||
|   void connectWithHmgNetwork() async { | ||||
|     try { | ||||
|       bool isConnected = await WiFiForIoTPlugin.connect("MOHEMM-CONNECT", password: "0987654321", joinOnce: Platform.isIOS ? false : true, security: NetworkSecurity.WPA, withInternet: false); | ||||
| 
 | ||||
|       if (isConnected) { | ||||
|         await WiFiForIoTPlugin.forceWifiUsage(true); | ||||
|         await Future.delayed(const Duration(seconds: 2)); | ||||
|         isConnectedToHMG=true; | ||||
| 
 | ||||
|       } | ||||
|     } catch (e) { | ||||
|       isConnectedToHMG = false; | ||||
|       AppState().isConnectedToHMG = isConnectedToHMG; | ||||
|       print("----------------o----"); | ||||
|       print(e); | ||||
|     } | ||||
|   } | ||||
| 
 | ||||
|   Future<bool> closeWifiRequest() async { | ||||
|     if (Platform.isAndroid) { | ||||
|       await WiFiForIoTPlugin.forceWifiUsage(false); | ||||
|     } | ||||
|     isConnectedToHMG = false; | ||||
|     AppState().isConnectedToHMG = isConnectedToHMG; | ||||
|     return await WiFiForIoTPlugin.disconnect(); | ||||
|   } | ||||
| } | ||||
| @ -0,0 +1,50 @@ | ||||
| import 'package:easy_localization/easy_localization.dart'; | ||||
| import 'package:flutter/material.dart'; | ||||
| import 'package:mohem_flutter_app/classes/colors.dart'; | ||||
| import 'package:mohem_flutter_app/extensions/int_extensions.dart'; | ||||
| import 'package:mohem_flutter_app/extensions/string_extensions.dart'; | ||||
| import 'package:mohem_flutter_app/generated/locale_keys.g.dart'; | ||||
| import 'package:mohem_flutter_app/provider/hmg_connection_provider.dart'; | ||||
| import 'package:provider/provider.dart'; | ||||
| 
 | ||||
| class HmgConnectivityButton extends StatelessWidget { | ||||
|   @override | ||||
|   Widget build(BuildContext context) { | ||||
|     Provider.of<HmgConnectionProvider>(context, listen: false).checkHmgNetworkConnectivity(); | ||||
|     return Consumer<HmgConnectionProvider>( | ||||
|       builder: (_, HmgConnectionProvider foo, __) { | ||||
|         return Container( | ||||
|           height: 45, | ||||
|           padding: const EdgeInsets.only(left: 12, right: 12), | ||||
|           decoration: BoxDecoration( | ||||
|             borderRadius: BorderRadius.circular(200.0), | ||||
|             gradient: const LinearGradient( | ||||
|               transform: GradientRotation(.83), | ||||
|               begin: Alignment.topRight, | ||||
|               end: Alignment.bottomLeft, | ||||
|               colors: <Color>[ | ||||
|                 MyColors.gradiantEndColor, | ||||
|                 MyColors.gradiantStartColor, | ||||
|               ], | ||||
|             ), | ||||
|           ), | ||||
|           child: InkWell( | ||||
|             onTap: (){ | ||||
| 
 | ||||
|             }, | ||||
|             child: Row( | ||||
|               children: [ | ||||
|                 const Icon( | ||||
|                   Icons.wifi, | ||||
|                   color: Colors.white, | ||||
|                 ), | ||||
|                 12.width, | ||||
|                 LocaleKeys.connectHmgWifi.tr().toText18(color: Colors.white), | ||||
|               ], | ||||
|             ), | ||||
|           ), | ||||
|         ); | ||||
|       }, | ||||
|     ); | ||||
|   } | ||||
| } | ||||
					Loading…
					
					
				
		Reference in New Issue