Offscreen

This commit is contained in:
sewmina7@gmail.com 2023-08-16 14:26:57 +05:30
parent 9c70330803
commit 0ada78e781
9 changed files with 253 additions and 24 deletions

View File

@ -16,6 +16,7 @@ class Debug{
if(!enableLogging){return;}
if(!enableErrorLoggin) {return;}
print('\x1B[31m$msg\x1B[0m');
print(StackTrace.current);
}
static void Log(Object? msg){

View File

@ -1,9 +1,11 @@
import 'package:animated_text_kit/animated_text_kit.dart';
import 'package:cached_network_image/cached_network_image.dart';
import 'package:connectivity_plus/connectivity_plus.dart';
import 'package:fhub/backend/DataManager.dart';
import 'package:fhub/backend/DebugHelper.dart';
import 'package:fhub/backend/Dialogs.dart';
import 'package:fhub/gameInfo.dart';
import 'package:fhub/off_screen.dart';
import 'package:fhub/src/CustomWidgets.dart';
import 'package:fhub/wd_history.dart';
import 'package:fhub/wd_portal.dart';
@ -32,6 +34,21 @@ class _HomeState extends State<Home> with WidgetsBindingObserver {
TxtCoinbaseAddress.text = DataManager.UserJson['wd_address'] ?? "";
WidgetsBinding.instance.addObserver(this);
subscription = Connectivity().onConnectivityChanged.listen((ConnectivityResult result) async{
// Got a new connectivity status!
try{
final connectivityResult = await (Connectivity().checkConnectivity());
Debug.Log(connectivityResult);
if(connectivityResult != ConnectivityResult.mobile && connectivityResult != ConnectivityResult.mobile && connectivityResult != ConnectivityResult.ethernet){
Navigator.of(context).pushReplacement(MaterialPageRoute(builder: (_)=>OfflinePage(id:0)));
return;
}
}catch(e){
}
});
}
@override
@ -40,6 +57,7 @@ class _HomeState extends State<Home> with WidgetsBindingObserver {
super.dispose();
WidgetsBinding.instance.removeObserver(this);
subscription.cancel();
}
@override
@ -74,6 +92,8 @@ class _HomeState extends State<Home> with WidgetsBindingObserver {
int selectedPageId = 0;
String TitleText = "Home";
var subscription;
@override
Widget build(BuildContext context) {
final screenHeight = MediaQuery.of(context).size.height;
@ -644,7 +664,9 @@ class _HomeState extends State<Home> with WidgetsBindingObserver {
{required String gameName,
required String coin,
required List<Widget> challengesInfo}) {
return GlassCard(
return Padding(
padding: const EdgeInsets.all(8.0),
child: GlassCard(
child: Container(
width: screenWidth * 0.8,
padding: EdgeInsets.all(15),
@ -665,7 +687,8 @@ class _HomeState extends State<Home> with WidgetsBindingObserver {
children: challengesInfo,
)
]),
));
)),
);
}
Widget ChallengeProgress(dynamic ChallengeData) {

114
lib/off_screen.dart Normal file
View File

@ -0,0 +1,114 @@
import 'package:external_app_launcher/external_app_launcher.dart';
import 'package:fhub/src/CustomWidgets.dart';
import 'package:flutter/material.dart';
class OfflinePage extends StatefulWidget {
OfflinePage({super.key,required this.id});
int id=0;
@override
State<OfflinePage> createState() => _OfflinePageState();
}
class _OfflinePageState extends State<OfflinePage> {
@override
void initState() {
// TODO: implement initState
super.initState();
kickstartAnimations();
}
void kickstartAnimations() async {
await Future.delayed(const Duration(milliseconds: 500));
setState(() {
op1 = 1;
op2 = 1;
op3 = 1;
});
}
@override
Widget build(BuildContext context) {
int id = widget.id;
// id = ;
return Scaffold(
backgroundColor: Colors.black,
extendBody: true,
body: CustomBody(
onAnimEnd: () {
setState(() {});
},
context: context,
child: Padding(
padding: const EdgeInsets.all(24.0),
child: id == 0 ? NoInternet() : ( id == 1 ? NewUpdate():Maintaince())
),
));
}
Widget NoInternet(){
return Column(
mainAxisAlignment: MainAxisAlignment.spaceBetween
,children: [
Center(child: GradientText(text:"No Internet", gradient: LinearGradient(colors: [Colors.white.withOpacity(0.6),Colors.white.withOpacity(0.2)]),style: TextStyle(fontSize: 50,fontWeight: FontWeight.bold),)),
Column(children:
[
Icon(Icons.signal_wifi_connected_no_internet_4,size: 105,color: Colors.white.withOpacity(0.4),),
Padding(
padding: const EdgeInsets.all(15.0),
child: Text("This app need an active internet connection to funtion.\nPlease Connect to Internet to continue.",textAlign: TextAlign.center,),
)
]
),
Column()
],);
}
Widget NewUpdate(){
return Column(
mainAxisAlignment: MainAxisAlignment.spaceBetween
,children: [
Center(child: GradientText(text:"New Update!", gradient: LinearGradient(colors: [Colors.white.withOpacity(0.6),Colors.white.withOpacity(0.2)]),style: TextStyle(fontSize: 50,fontWeight: FontWeight.bold),)),
Column(children:
[
Icon(Icons.download_outlined,size: 100,color: Colors.white.withOpacity(0.4),),
Padding(
padding: const EdgeInsets.all(15.0),
child: Text("Please Update to continue.",textAlign: TextAlign.center,),
),
SizedBox(height: 30,),
GlassButton(onTap: () async{
await LaunchApp.openApp(
androidPackageName: "https://play.google.com/store/apps/details?id=com.Xperience.FaucetHub",
// openStore: false
);
}, child: Text("Update",style: TextStyle(fontSize: 18,fontWeight: FontWeight.bold),), width: 200,height: 50,color: Colors.greenAccent)
]
),
Column()
],);
}
Widget Maintaince(){
return Column(
mainAxisAlignment: MainAxisAlignment.spaceBetween
,children: [
Center(child: GradientText(text:"Under Maintaince!", gradient: LinearGradient(colors: [Colors.white.withOpacity(0.6),Colors.white.withOpacity(0.2)]),style: TextStyle(fontSize: 38,fontWeight: FontWeight.bold),)),
Column(children:
[
Icon(Icons.developer_mode_outlined,size: 100,color: Colors.white.withOpacity(0.4),),
Padding(
padding: const EdgeInsets.all(30.0),
child: Text("Please Check back in later.",textAlign: TextAlign.center,),
),
]
),
Column()
],);
}
}

View File

@ -1,12 +1,15 @@
import 'dart:async';
import 'package:fhub/backend/DataManager.dart';
import 'package:fhub/backend/Dialogs.dart';
import 'package:fhub/backend/login_mgr.dart';
import 'package:fhub/disabled_mode.dart';
import 'package:fhub/home.dart';
import 'package:fhub/off_screen.dart';
import 'package:fhub/src/CustomWidgets.dart';
import 'package:flutter/material.dart';
import 'package:google_sign_in/google_sign_in.dart';
import 'package:connectivity_plus/connectivity_plus.dart';
import 'backend/DebugHelper.dart';
class MyHomePage extends StatefulWidget {
@ -15,7 +18,7 @@ class MyHomePage extends StatefulWidget {
@override
State<MyHomePage> createState() => _MyHomePageState();
}
var subscription;
class _MyHomePageState extends State<MyHomePage> {
int counter = -1;
bool loginLoading = false;
@ -25,9 +28,34 @@ class _MyHomePageState extends State<MyHomePage> {
super.initState();
kickstartAnimations();
init();
subscription = Connectivity().onConnectivityChanged.listen((ConnectivityResult result) async{
// Got a new connectivity status!
try{
final connectivityResult = await (Connectivity().checkConnectivity());
Debug.Log(connectivityResult);
if(connectivityResult != ConnectivityResult.mobile && connectivityResult != ConnectivityResult.mobile && connectivityResult != ConnectivityResult.ethernet){
Navigator.of(context).pushReplacement(MaterialPageRoute(builder: (_)=>OfflinePage(id:0)));
return;
}
}catch(e){
}
});
}
@override
void dispose() {
// TODO: implement dispose
super.dispose();
subscription.cancel();
}
void init() async{
int serverVersion = await DataManager.GetVersion();
if(serverVersion > 0 && serverVersion != DataManager.ClientVersion){
Navigator.of(context).push(MaterialPageRoute(builder: (context)=> UpdatePage()));

View File

@ -5,6 +5,7 @@
import FlutterMacOS
import Foundation
import connectivity_plus
import firebase_auth
import firebase_core
import path_provider_foundation
@ -13,6 +14,7 @@ import sqflite
import url_launcher_macos
func RegisterGeneratedPlugins(registry: FlutterPluginRegistry) {
ConnectivityPlugin.register(with: registry.registrar(forPlugin: "ConnectivityPlugin"))
FLTFirebaseAuthPlugin.register(with: registry.registrar(forPlugin: "FLTFirebaseAuthPlugin"))
FLTFirebaseCorePlugin.register(with: registry.registrar(forPlugin: "FLTFirebaseCorePlugin"))
PathProviderPlugin.register(with: registry.registrar(forPlugin: "PathProviderPlugin"))

View File

@ -17,6 +17,14 @@ packages:
url: "https://pub.dev"
source: hosted
version: "4.2.2"
args:
dependency: transitive
description:
name: args
sha256: eef6c46b622e0494a36c5a12d10d77fb4e855501a91c1b9ef9339326e58f0596
url: "https://pub.dev"
source: hosted
version: "2.4.2"
async:
dependency: transitive
description:
@ -89,6 +97,22 @@ packages:
url: "https://pub.dev"
source: hosted
version: "1.17.1"
connectivity_plus:
dependency: "direct main"
description:
name: connectivity_plus
sha256: "77a180d6938f78ca7d2382d2240eb626c0f6a735d0bfdce227d8ffb80f95c48b"
url: "https://pub.dev"
source: hosted
version: "4.0.2"
connectivity_plus_platform_interface:
dependency: transitive
description:
name: connectivity_plus_platform_interface
sha256: cf1d1c28f4416f8c654d7dc3cd638ec586076255d407cef3ddbdaf178272a71a
url: "https://pub.dev"
source: hosted
version: "1.2.4"
crypto:
dependency: transitive
description:
@ -113,6 +137,14 @@ packages:
url: "https://pub.dev"
source: hosted
version: "1.0.5"
dbus:
dependency: transitive
description:
name: dbus
sha256: "6f07cba3f7b3448d42d015bfd3d53fe12e5b36da2423f23838efc1d5fb31a263"
url: "https://pub.dev"
source: hosted
version: "0.7.8"
external_app_launcher:
dependency: "direct main"
description:
@ -344,6 +376,14 @@ packages:
url: "https://pub.dev"
source: hosted
version: "1.9.1"
nm:
dependency: transitive
description:
name: nm
sha256: "2c9aae4127bdc8993206464fcc063611e0e36e72018696cd9631023a31b24254"
url: "https://pub.dev"
source: hosted
version: "0.5.0"
octo_image:
dependency: transitive
description:
@ -408,6 +448,14 @@ packages:
url: "https://pub.dev"
source: hosted
version: "2.1.7"
petitparser:
dependency: transitive
description:
name: petitparser
sha256: cb3798bef7fc021ac45b308f4b51208a152792445cce0448c9a4ba5879dd8750
url: "https://pub.dev"
source: hosted
version: "5.4.0"
platform:
dependency: transitive
description:
@ -685,6 +733,14 @@ packages:
url: "https://pub.dev"
source: hosted
version: "1.0.0"
xml:
dependency: transitive
description:
name: xml
sha256: "5bc72e1e45e941d825fd7468b9b4cc3b9327942649aeb6fc5cdbf135f0a86e84"
url: "https://pub.dev"
source: hosted
version: "6.3.0"
sdks:
dart: ">=3.0.1 <4.0.0"
flutter: ">=3.3.0"

View File

@ -43,6 +43,7 @@ dependencies:
url_launcher: ^6.1.11
intl: ^0.18.1
cached_network_image: ^3.2.3
connectivity_plus: ^4.0.2
dev_dependencies:
flutter_test:

View File

@ -6,10 +6,13 @@
#include "generated_plugin_registrant.h"
#include <connectivity_plus/connectivity_plus_windows_plugin.h>
#include <firebase_core/firebase_core_plugin_c_api.h>
#include <url_launcher_windows/url_launcher_windows.h>
void RegisterPlugins(flutter::PluginRegistry* registry) {
ConnectivityPlusWindowsPluginRegisterWithRegistrar(
registry->GetRegistrarForPlugin("ConnectivityPlusWindowsPlugin"));
FirebaseCorePluginCApiRegisterWithRegistrar(
registry->GetRegistrarForPlugin("FirebaseCorePluginCApi"));
UrlLauncherWindowsRegisterWithRegistrar(

View File

@ -3,6 +3,7 @@
#
list(APPEND FLUTTER_PLUGIN_LIST
connectivity_plus
firebase_core
url_launcher_windows
)