convert swtich offline into bloc

feature/passo/PASSO-#1-Sync-data-from-device-to-postgre-and-vice-versa
unknown 2023-10-06 20:19:06 +08:00
parent f9fd714fa6
commit ebb04ad358
15 changed files with 245 additions and 135 deletions

View File

@ -0,0 +1,28 @@
import 'package:bloc/bloc.dart';
import 'package:equatable/equatable.dart';
import 'package:unit2/utils/global.dart';
import '../../../model/offline/offlane_modules.dart';
import '../../../model/offline/offline_profile.dart';
part 'offline_event.dart';
part 'offline_state.dart';
class OfflineBloc extends Bloc<OfflineEvent, OfflineState> {
OfflineBloc() : super(OfflineInitial()) {
on<SwitchOffline>((event, emit) async {
try {
List<dynamic> modules = await OFFLINE!.get('modules');
List<OfflineModules> offlineModules = [];
for (var module in modules) {
offlineModules.add(module);
}
OfflineProfile offlineProfile = await OFFLINE!.get('offline_profile');
emit(OfflineModeState(
offlineModules: offlineModules, offlineProfile: offlineProfile));
} catch (e) {
emit(OfflineErrorState(message: e.toString()));
}
});
}
}

View File

@ -0,0 +1,13 @@
part of 'offline_bloc.dart';
class OfflineEvent extends Equatable {
const OfflineEvent();
@override
List<Object> get props => [];
}
class SwitchOffline extends OfflineEvent {
@override
List<Object> get props => [];
}

View File

@ -0,0 +1,26 @@
part of 'offline_bloc.dart';
class OfflineState extends Equatable {
const OfflineState();
@override
List<Object> get props => [];
}
class OfflineInitial extends OfflineState {}
class OfflineModeState extends OfflineState {
final OfflineProfile offlineProfile;
final List<OfflineModules> offlineModules;
const OfflineModeState(
{required this.offlineModules, required this.offlineProfile});
@override
List<Object> get props => [offlineProfile, offlineModules];
}
class OfflineLoadingState extends OfflineState {}
class OfflineErrorState extends OfflineState {
final String message;
const OfflineErrorState({required this.message});
}

View File

@ -10,7 +10,7 @@ class GetApkVersion extends UserEvent {
final String password; final String password;
GetApkVersion({required this.password, required this.username}); GetApkVersion({required this.password, required this.username});
@override @override
List<Object> get props => [username,password]; List<Object> get props => [username, password];
} }
class UserLogin extends UserEvent { class UserLogin extends UserEvent {
@ -28,15 +28,15 @@ class LoadLoggedInUser extends UserEvent {
class GetUuid extends UserEvent { class GetUuid extends UserEvent {
GetUuid(); GetUuid();
} }
class LoadUuid extends UserEvent{
class LoadUuid extends UserEvent {
LoadUuid(); LoadUuid();
} }
class LoadVersion extends UserEvent { class LoadVersion extends UserEvent {
final String? username; final String? username;
final String? password; final String? password;
LoadVersion({this.password,this.username}); LoadVersion({this.password, this.username});
} }
class UuidLogin extends UserEvent { class UuidLogin extends UserEvent {

View File

@ -1,43 +1,47 @@
part of 'user_bloc.dart'; part of 'user_bloc.dart';
abstract class UserState extends Equatable { abstract class UserState extends Equatable {
@override @override
List<Object> get props => []; List<Object> get props => [];
} }
class UserInitial extends UserState { class UserInitial extends UserState {
UserInitial(); UserInitial();
@override @override
List<Object> get props => []; List<Object> get props => [];
} }
class UserLoading extends UserState { class UserLoading extends UserState {
final String? message; final String? message;
UserLoading({this.message}); UserLoading({this.message});
@override @override
List<Object> get props => [message!]; List<Object> get props => [message!];
} }
class SplashScreen extends UserState { class SplashScreen extends UserState {
@override @override
List<Object> get props => []; List<Object> get props => [];
} }
class UserError extends UserState { class UserError extends UserState {
final String? message; final String? message;
UserError({this.message}); UserError({this.message});
@override @override
List<Object> get props => []; List<Object> get props => [];
} }
class UserLoggedIn extends UserState{
class UserLoggedIn extends UserState {
final List<AssignedArea>? estPersonAssignedArea; final List<AssignedArea>? estPersonAssignedArea;
final UserData? userData; final UserData? userData;
final String? message; final String? message;
final bool? success; final bool? success;
final bool? savedCredentials; final bool? savedCredentials;
UserLoggedIn({this.userData,this.message,this.success,this.savedCredentials, required this.estPersonAssignedArea}); UserLoggedIn(
{this.userData,
this.message,
this.success,
this.savedCredentials,
required this.estPersonAssignedArea});
} }
class VersionLoaded extends UserState { class VersionLoaded extends UserState {
@ -45,33 +49,34 @@ class VersionLoaded extends UserState {
final String? apkVersion; final String? apkVersion;
final String? username; final String? username;
final String? password; final String? password;
VersionLoaded({this.versionInfo,this.apkVersion, this.password,this.username}); VersionLoaded(
{this.versionInfo, this.apkVersion, this.password, this.username});
@override @override
List<Object> get props => [versionInfo!]; List<Object> get props => [versionInfo!];
} }
class UuidLoaded extends UserState{
class UuidLoaded extends UserState {
final String uuid; final String uuid;
UuidLoaded({required this.uuid}); UuidLoaded({required this.uuid});
@override @override
List<Object> get props => [uuid]; List<Object> get props => [uuid];
} }
class InternetTimeout extends UserState{ class InternetTimeout extends UserState {
final String message; final String message;
InternetTimeout({required this.message}); InternetTimeout({required this.message});
@override @override
List<Object> get props => [message]; List<Object> get props => [message];
} }
class InvalidCredentials extends UserState{ class InvalidCredentials extends UserState {
final String message ; final String message;
InvalidCredentials ({required this.message}); InvalidCredentials({required this.message});
} }
class LoginErrorState extends UserState{
class LoginErrorState extends UserState {
final String message; final String message;
LoginErrorState({required this.message}); LoginErrorState({required this.message});
} }
class ErrorWithOfflineMode extends UserState{ class ErrorWithOfflineMode extends UserState {}
}

View File

@ -9,35 +9,34 @@ import '../../../../bloc/user/user_bloc.dart';
import '../../../../widgets/splash_screen.dart'; import '../../../../widgets/splash_screen.dart';
class OfflineDrawerScreen extends StatefulWidget { class OfflineDrawerScreen extends StatefulWidget {
final List<OfflineModules> modules; const OfflineDrawerScreen({
const OfflineDrawerScreen({Key? key ,required this.modules}) : super(key: key,); Key? key,
}) : super(
key: key,
);
@override @override
State<OfflineDrawerScreen> createState() => _OfflineDrawerScreenState(); State<OfflineDrawerScreen> createState() => _OfflineDrawerScreenState();
} }
class _OfflineDrawerScreenState extends State<OfflineDrawerScreen> { class _OfflineDrawerScreenState extends State<OfflineDrawerScreen> {
final zoomDrawerController = ZoomDrawerController(); final zoomDrawerController = ZoomDrawerController();
@override @override
@override @override
Widget build(BuildContext context) { Widget build(BuildContext context) {
return ZoomDrawer( return ZoomDrawer(
controller: zoomDrawerController, controller: zoomDrawerController,
menuScreen: const OfflineMenuScreen(), menuScreen: const OfflineMenuScreen(),
mainScreen: SizedBox( mainScreen: SizedBox(
height: MediaQuery.of(context).size.height, height: MediaQuery.of(context).size.height,
child: OfflineModuleScreen(modules: widget.modules,)), child: const OfflineModuleScreen()),
style: DrawerStyle.defaultStyle, style: DrawerStyle.defaultStyle,
borderRadius: 24.0, borderRadius: 24.0,
showShadow: false, showShadow: false,
angle: -0.0, angle: -0.0,
slideWidth: MediaQuery.of(context).size.width * .90, slideWidth: MediaQuery.of(context).size.width * .90,
openCurve: Curves.fastOutSlowIn, openCurve: Curves.fastOutSlowIn,
closeCurve: Curves.easeOut, closeCurve: Curves.easeOut,
menuBackgroundColor: Colors.grey, menuBackgroundColor: Colors.grey,
); );
} }
} }

View File

@ -1,14 +1,15 @@
import 'package:flutter/material.dart'; import 'package:flutter/material.dart';
import 'package:flutter_bloc/flutter_bloc.dart';
import 'package:flutter_zoom_drawer/flutter_zoom_drawer.dart'; import 'package:flutter_zoom_drawer/flutter_zoom_drawer.dart';
import 'package:fluttericon/font_awesome5_icons.dart'; import 'package:fluttericon/font_awesome5_icons.dart';
import 'package:unit2/bloc/offline/offline_bloc/offline_bloc.dart';
import 'package:unit2/model/offline/offlane_modules.dart'; import 'package:unit2/model/offline/offlane_modules.dart';
import 'package:unit2/screens/passo/passo_dashboard.dart'; import 'package:unit2/screens/passo/passo_dashboard.dart';
import 'package:unit2/screens/unit2/homepage.dart/components/dashboard/shared_card_label.dart'; import 'package:unit2/screens/unit2/homepage.dart/components/dashboard/shared_card_label.dart';
import 'package:unit2/theme-data.dart/colors.dart'; import 'package:unit2/theme-data.dart/colors.dart';
class OfflineModuleScreen extends StatelessWidget { class OfflineModuleScreen extends StatelessWidget {
final List<OfflineModules> modules; const OfflineModuleScreen({super.key});
const OfflineModuleScreen({super.key, required this.modules});
@override @override
Widget build(BuildContext context) { Widget build(BuildContext context) {
@ -27,25 +28,37 @@ class OfflineModuleScreen extends StatelessWidget {
), ),
), ),
), ),
body: Padding( body: BlocConsumer<OfflineBloc, OfflineState>(
padding: const EdgeInsets.all(24), listener: (context, state) {
child: GridView.count( // TODO: implement listener
shrinkWrap: true, },
crossAxisCount: 4, builder: (context, state) {
crossAxisSpacing: 8, if (state is OfflineModeState) {
mainAxisSpacing: 10, return Padding(
physics: const BouncingScrollPhysics(), padding: const EdgeInsets.all(24),
padding: const EdgeInsets.symmetric(vertical: 5, horizontal: 5), child: GridView.count(
children: modules shrinkWrap: true,
.map((e) => CardLabel( crossAxisCount: 4,
icon: FontAwesome5.eye, crossAxisSpacing: 8,
title: "Field Surveyor", mainAxisSpacing: 10,
ontap: () { physics: const BouncingScrollPhysics(),
Navigator.push(context, MaterialPageRoute(builder: ((context) { padding:
return PassoDashBoard(); const EdgeInsets.symmetric(vertical: 5, horizontal: 5),
}))); children: state.offlineModules
})) .map((e) => CardLabel(
.toList()), icon: FontAwesome5.eye,
title: "Field Surveyor",
ontap: () {
Navigator.push(context,
MaterialPageRoute(builder: ((context) {
return PassoDashBoard();
})));
}))
.toList()),
);
}
return Container();
},
)); ));
} }
} }

View File

@ -44,7 +44,6 @@ import '../../bloc/profile/voluntary_works/voluntary_work_bloc.dart';
import '../../bloc/profile/workHistory/workHistory_bloc.dart'; import '../../bloc/profile/workHistory/workHistory_bloc.dart';
import '../../bloc/user/user_bloc.dart'; import '../../bloc/user/user_bloc.dart';
import '../../model/profile/basic_information/primary-information.dart'; import '../../model/profile/basic_information/primary-information.dart';
import '../unit2/homepage.dart/components/menu.dart';
import 'components/main_menu.dart'; import 'components/main_menu.dart';
import 'components/submenu.dart'; import 'components/submenu.dart';
@ -62,10 +61,8 @@ class _ProfileInfoState extends State<ProfileInfo> {
String? token; String? token;
Profile profile; Profile profile;
return WillPopScope( return WillPopScope(
onWillPop: () async{ onWillPop: () async {
setState(() { setState(() {});
});
return true; return true;
}, },
child: Scaffold( child: Scaffold(
@ -83,9 +80,8 @@ class _ProfileInfoState extends State<ProfileInfo> {
profileId = state.userData!.user!.login!.user!.profileId; profileId = state.userData!.user!.login!.user!.profileId;
token = state.userData!.user!.login!.token!; token = state.userData!.user!.login!.token!;
if (globalCurrentProfile == null) { if (globalCurrentProfile == null) {
profile = state.userData!.employeeInfo!.profile!; profile = state.userData!.employeeInfo!.profile!;
globalCurrentProfile = profile; globalCurrentProfile = profile;
} else { } else {
profile = globalCurrentProfile!; profile = globalCurrentProfile!;
} }
@ -120,7 +116,8 @@ class _ProfileInfoState extends State<ProfileInfo> {
ExpandableGroup( ExpandableGroup(
collapsedIcon: collapsedIcon:
const Icon(Icons.keyboard_arrow_down), const Icon(Icons.keyboard_arrow_down),
expandedIcon: const Icon(Icons.keyboard_arrow_up), expandedIcon:
const Icon(Icons.keyboard_arrow_up),
header: const ListTile( header: const ListTile(
leading: Icon( leading: Icon(
Elusive.address_book, Elusive.address_book,
@ -128,7 +125,8 @@ class _ProfileInfoState extends State<ProfileInfo> {
), ),
title: Text( title: Text(
"Basic Information", "Basic Information",
style: TextStyle(fontWeight: FontWeight.bold), style:
TextStyle(fontWeight: FontWeight.bold),
), ),
), ),
items: [ items: [
@ -138,7 +136,8 @@ class _ProfileInfoState extends State<ProfileInfo> {
return BlocProvider<ProfileBloc>.value( return BlocProvider<ProfileBloc>.value(
value: ProfileBloc() value: ProfileBloc()
..add(GetPrimaryBasicInfo( ..add(GetPrimaryBasicInfo(
primaryBasicInformation: profile)), primaryBasicInformation:
profile)),
child: PrimaryInfo( child: PrimaryInfo(
token: token!, token: token!,
profileId: profileId!, profileId: profileId!,
@ -152,8 +151,10 @@ class _ProfileInfoState extends State<ProfileInfo> {
return BlocProvider( return BlocProvider(
create: (context) => AddressBloc() create: (context) => AddressBloc()
..add(GetAddress( ..add(GetAddress(
addresses: state.profileInformation addresses: state
.basicInfo.addresses)), .profileInformation
.basicInfo
.addresses)),
child: const AddressScreen(), child: const AddressScreen(),
); );
})); }));
@ -163,12 +164,14 @@ class _ProfileInfoState extends State<ProfileInfo> {
Navigator.push(context, MaterialPageRoute( Navigator.push(context, MaterialPageRoute(
builder: (BuildContext context) { builder: (BuildContext context) {
return BlocProvider( return BlocProvider(
create: (context) => IdentificationBloc() create: (context) =>
..add(GetIdentifications( IdentificationBloc()
identificationInformation: state ..add(GetIdentifications(
.profileInformation identificationInformation:
.basicInfo state
.identifications)), .profileInformation
.basicInfo
.identifications)),
child: const IdentificationsScreen(), child: const IdentificationsScreen(),
); );
})); }));
@ -199,11 +202,12 @@ class _ProfileInfoState extends State<ProfileInfo> {
.basicInfo .basicInfo
.citizenships)), .citizenships)),
child: CitizenShipScreen( child: CitizenShipScreen(
citizenships: state citizenships: state
.profileInformation .profileInformation
.basicInfo .basicInfo
.citizenships, .citizenships,
profileId: profileId!, token: token!), profileId: profileId!,
token: token!),
); );
})); }));
}), }),
@ -218,7 +222,8 @@ class _ProfileInfoState extends State<ProfileInfo> {
return BlocProvider( return BlocProvider(
create: (context) => FamilyBloc() create: (context) => FamilyBloc()
..add(GetFamilies( ..add(GetFamilies(
profileId: profileId!, token: token!)), profileId: profileId!,
token: token!)),
child: const FamilyBackgroundScreen(), child: const FamilyBackgroundScreen(),
); );
})); }));
@ -234,7 +239,8 @@ class _ProfileInfoState extends State<ProfileInfo> {
return BlocProvider( return BlocProvider(
create: (context) => EducationBloc() create: (context) => EducationBloc()
..add(GetEducationalBackground( ..add(GetEducationalBackground(
profileId: profileId!, token: token!)), profileId: profileId!,
token: token!)),
child: const EducationScreen(), child: const EducationScreen(),
); );
})); }));
@ -250,7 +256,8 @@ class _ProfileInfoState extends State<ProfileInfo> {
return BlocProvider( return BlocProvider(
create: (context) => EligibilityBloc() create: (context) => EligibilityBloc()
..add(GetEligibilities( ..add(GetEligibilities(
profileId: profileId!, token: token!)), profileId: profileId!,
token: token!)),
child: const EligibiltyScreen(), child: const EligibiltyScreen(),
); );
})); }));
@ -266,7 +273,8 @@ class _ProfileInfoState extends State<ProfileInfo> {
return BlocProvider( return BlocProvider(
create: (context) => WorkHistoryBloc() create: (context) => WorkHistoryBloc()
..add(GetWorkHistories( ..add(GetWorkHistories(
profileId: profileId!, token: token!)), profileId: profileId!,
token: token!)),
child: const WorkHistoryScreen(), child: const WorkHistoryScreen(),
); );
})); }));
@ -282,7 +290,8 @@ class _ProfileInfoState extends State<ProfileInfo> {
return BlocProvider( return BlocProvider(
create: (context) => VoluntaryWorkBloc() create: (context) => VoluntaryWorkBloc()
..add(GetVoluntarWorks( ..add(GetVoluntarWorks(
profileId: profileId!, token: token!)), profileId: profileId!,
token: token!)),
child: const VolunataryWorkScreen(), child: const VolunataryWorkScreen(),
); );
})); }));
@ -296,9 +305,11 @@ class _ProfileInfoState extends State<ProfileInfo> {
Navigator.push(context, MaterialPageRoute( Navigator.push(context, MaterialPageRoute(
builder: (BuildContext context) { builder: (BuildContext context) {
return BlocProvider( return BlocProvider(
create: (context) => LearningDevelopmentBloc() create: (context) =>
..add(GetLearningDevelopments( LearningDevelopmentBloc()
profileId: profileId!, token: token!)), ..add(GetLearningDevelopments(
profileId: profileId!,
token: token!)),
child: const LearningAndDevelopmentScreen(), child: const LearningAndDevelopmentScreen(),
); );
})); }));
@ -314,7 +325,8 @@ class _ProfileInfoState extends State<ProfileInfo> {
return BlocProvider( return BlocProvider(
create: (context) => ReferencesBloc() create: (context) => ReferencesBloc()
..add(GetReferences( ..add(GetReferences(
profileId: profileId!, token: token!)), profileId: profileId!,
token: token!)),
child: const ReferencesScreen(), child: const ReferencesScreen(),
); );
})); }));
@ -323,7 +335,8 @@ class _ProfileInfoState extends State<ProfileInfo> {
ExpandableGroup( ExpandableGroup(
collapsedIcon: collapsedIcon:
const Icon(Icons.keyboard_arrow_down), const Icon(Icons.keyboard_arrow_down),
expandedIcon: const Icon(Icons.keyboard_arrow_up), expandedIcon:
const Icon(Icons.keyboard_arrow_up),
header: const ListTile( header: const ListTile(
leading: Icon( leading: Icon(
Icons.info, Icons.info,
@ -331,7 +344,8 @@ class _ProfileInfoState extends State<ProfileInfo> {
), ),
title: Text( title: Text(
"Other Information", "Other Information",
style: TextStyle(fontWeight: FontWeight.bold), style:
TextStyle(fontWeight: FontWeight.bold),
), ),
), ),
items: [ items: [
@ -382,7 +396,8 @@ class _ProfileInfoState extends State<ProfileInfo> {
ExpandableGroup( ExpandableGroup(
collapsedIcon: collapsedIcon:
const Icon(Icons.keyboard_arrow_down), const Icon(Icons.keyboard_arrow_down),
expandedIcon: const Icon(Icons.keyboard_arrow_up), expandedIcon:
const Icon(Icons.keyboard_arrow_up),
header: const ListTile( header: const ListTile(
leading: Icon( leading: Icon(
FontAwesome5.laptop_house, FontAwesome5.laptop_house,
@ -390,7 +405,8 @@ class _ProfileInfoState extends State<ProfileInfo> {
), ),
title: Text( title: Text(
"Assets", "Assets",
style: TextStyle(fontWeight: FontWeight.bold), style:
TextStyle(fontWeight: FontWeight.bold),
), ),
), ),
items: [ items: [
@ -412,7 +428,7 @@ class _ProfileInfoState extends State<ProfileInfo> {
LoadProfile(token: token!, userID: profileId!)); LoadProfile(token: token!, userID: profileId!));
}); });
} }
return Container(); return Container();
}, },
); );

View File

@ -137,10 +137,10 @@ class BuildInformation extends StatelessWidget {
@override @override
Widget build(BuildContext context) { Widget build(BuildContext context) {
DateFormat dteFormat2 = DateFormat.yMMMMd('en_US'); DateFormat dteFormat2 = DateFormat.yMMMMd('en_US');
globalFistname = globalFistname = globalFistname ??
globalFistname ?? userData.employeeInfo!.profile!.firstName!.toUpperCase(); userData.employeeInfo!.profile!.firstName!.toUpperCase();
globalLastname = globalLastname = globalLastname ??
globalLastname ?? userData.employeeInfo!.profile!.lastName!.toUpperCase(); userData.employeeInfo!.profile!.lastName!.toUpperCase();
globalMiddleName = globalMiddleName ?? globalMiddleName = globalMiddleName ??
(userData.employeeInfo == null (userData.employeeInfo == null
? '' ? ''
@ -182,7 +182,7 @@ class BuildInformation extends StatelessWidget {
return QRFullScreenImage(uuid: uuid); return QRFullScreenImage(uuid: uuid);
})); }));
}, },
child: QrImageView( child: QrImage(
data: uuid!, data: uuid!,
size: blockSizeVertical * 24, size: blockSizeVertical * 24,
), ),

View File

@ -12,12 +12,12 @@ class QRFullScreenImage extends StatelessWidget {
return Scaffold( return Scaffold(
appBar: AppBar( appBar: AppBar(
centerTitle: true, centerTitle: true,
backgroundColor: primary,title: const Text("Profile QR Code"),), backgroundColor: primary,
body: Center( title: const Text("Profile QR Code"),
child: QrImageView( ),
data: uuid, body: Center(
size: blockSizeVertical * 50 child: QrImage(data: uuid, size: blockSizeVertical * 50),
), ),
),); );
} }
} }

View File

@ -1,14 +1,16 @@
import 'package:flutter/material.dart'; import 'package:flutter/material.dart';
import 'package:flutter_bloc/flutter_bloc.dart';
import 'package:unit2/bloc/offline/offline_bloc/offline_bloc.dart';
import 'package:unit2/model/offline/offlane_modules.dart'; import 'package:unit2/model/offline/offlane_modules.dart';
import 'package:unit2/screens/offline/homepage/drawer.dart'; import 'package:unit2/screens/offline/homepage/drawer.dart';
import 'package:unit2/screens/offline/homepage/menu_screen.dart'; import 'package:unit2/screens/offline/homepage/menu_screen.dart';
import 'package:unit2/screens/unit2/homepage.dart/components/drawer-screen.dart'; import 'package:unit2/screens/unit2/homepage.dart/components/drawer-screen.dart';
import 'package:unit2/screens/unit2/homepage.dart/components/menu_tile.dart';
import 'package:unit2/theme-data.dart/colors.dart'; import 'package:unit2/theme-data.dart/colors.dart';
import 'package:fluttericon/web_symbols_icons.dart'; import 'package:fluttericon/web_symbols_icons.dart';
import 'package:fluttericon/font_awesome5_icons.dart'; import 'package:fluttericon/font_awesome5_icons.dart';
import 'package:unit2/utils/global_context.dart'; import 'package:unit2/utils/global_context.dart';
import '../../../../model/login_data/user_info/user_data.dart'; import '../../../../model/login_data/user_info/user_data.dart';
import 'menu.dart';
import '../../../../utils/global.dart'; import '../../../../utils/global.dart';
class MenuScreen extends StatefulWidget { class MenuScreen extends StatefulWidget {
@ -69,14 +71,20 @@ class _MenuScreenState extends State<MenuScreen> {
), ),
title: const Text( title: const Text(
"Offline Mode", "Offline Mode",
style: TextStyle(color: Colors.black), style: TextStyle(color: Colors.black),
), ),
onTap: () async { onTap: () async {
List<OfflineModules> modules = await OFFLINE!.get('modules'); Navigator.pushReplacement(
Navigator.pushReplacement(NavigationService.navigatorKey.currentState!.context, NavigationService
.navigatorKey.currentState!.context,
MaterialPageRoute(builder: ((context) { MaterialPageRoute(builder: ((context) {
return OfflineDrawerScreen(modules: modules,); return BlocProvider(
create: (context) =>
OfflineBloc()..add(SwitchOffline()),
child: const OfflineDrawerScreen(),
);
}))); })));
;
}, },
) )
: Container()) : Container())

View File

@ -7,6 +7,7 @@ import 'package:fluttericon/font_awesome5_icons.dart';
import 'package:fluttertoast/fluttertoast.dart'; import 'package:fluttertoast/fluttertoast.dart';
import 'package:form_builder_validators/form_builder_validators.dart'; import 'package:form_builder_validators/form_builder_validators.dart';
import 'package:flutter_progress_hud/flutter_progress_hud.dart'; import 'package:flutter_progress_hud/flutter_progress_hud.dart';
import 'package:unit2/bloc/offline/offline_bloc/offline_bloc.dart';
import 'package:unit2/model/offline/offlane_modules.dart'; import 'package:unit2/model/offline/offlane_modules.dart';
import 'package:unit2/screens/offline/homepage/drawer.dart'; import 'package:unit2/screens/offline/homepage/drawer.dart';
import 'package:unit2/screens/unit2/login/components/update_required.dart'; import 'package:unit2/screens/unit2/login/components/update_required.dart';
@ -401,16 +402,18 @@ class _UniT2LoginState extends State<UniT2Login> {
width: 200, width: 200,
height: 50, height: 50,
child: ElevatedButton.icon( child: ElevatedButton.icon(
icon: const Icon(Icons.signal_cellular_alt), icon: const Icon(Icons.signal_cellular_alt),
style: mainBtnStyle(second, Colors.transparent, primary), style:
mainBtnStyle(second, Colors.transparent, primary),
onPressed: () async { onPressed: () async {
List<OfflineModules> offlinemodules = await OFFLINE!.get('modules');
Navigator.pushReplacement( Navigator.pushReplacement(
NavigationService NavigationService
.navigatorKey.currentState!.context, .navigatorKey.currentState!.context,
MaterialPageRoute(builder: ((context) { MaterialPageRoute(builder: ((context) {
return OfflineDrawerScreen( return BlocProvider(
modules: offlinemodules, create: (context) =>
OfflineBloc()..add(SwitchOffline()),
child: const OfflineDrawerScreen(),
); );
}))); })));
}, },

View File

@ -1,15 +1,11 @@
import 'package:flutter/material.dart'; import 'package:flutter/material.dart';
import 'package:flutter_bloc/flutter_bloc.dart'; import 'package:flutter_bloc/flutter_bloc.dart';
import 'package:unit2/bloc/passo/bulding/property_info/property_info_bloc.dart';
import 'package:unit2/bloc/profile/profile_bloc.dart'; import 'package:unit2/bloc/profile/profile_bloc.dart';
import 'package:unit2/bloc/role/pass_check/pass_check_bloc.dart'; import 'package:unit2/bloc/role/pass_check/pass_check_bloc.dart';
import 'package:unit2/bloc/sos/sos_bloc.dart'; import 'package:unit2/bloc/sos/sos_bloc.dart';
import 'package:unit2/model/passo/property_info.dart';
import 'package:unit2/screens/passo/passo_dashboard.dart'; import 'package:unit2/screens/passo/passo_dashboard.dart';
import 'package:unit2/screens/passo/building_home.dart';
import 'package:unit2/screens/sos/index.dart'; import 'package:unit2/screens/sos/index.dart';
import 'package:unit2/screens/unit2/homepage.dart/components/dashboard/dashboard.dart'; import 'package:unit2/screens/unit2/homepage.dart/components/dashboard/dashboard.dart';
import 'package:unit2/screens/unit2/homepage.dart/components/menu.dart';
import 'package:unit2/screens/unit2/login/login.dart'; import 'package:unit2/screens/unit2/login/login.dart';
import 'package:unit2/screens/unit2/roles/rbac/rbac.dart'; import 'package:unit2/screens/unit2/roles/rbac/rbac.dart';
import 'package:unit2/utils/global_context.dart'; import 'package:unit2/utils/global_context.dart';
@ -18,6 +14,7 @@ import '../bloc/user/user_bloc.dart';
import '../screens/profile/profile.dart'; import '../screens/profile/profile.dart';
import '../screens/unit2/basic-info/basic-info.dart'; import '../screens/unit2/basic-info/basic-info.dart';
import '../screens/unit2/homepage.dart/components/drawer-screen.dart'; import '../screens/unit2/homepage.dart/components/drawer-screen.dart';
import '../screens/unit2/homepage.dart/components/menu_tile.dart';
import '../screens/unit2/login/qr_login.dart'; import '../screens/unit2/login/qr_login.dart';
import '../screens/unit2/roles/qr_code_scanner.dart/settings_screen.dart'; import '../screens/unit2/roles/qr_code_scanner.dart/settings_screen.dart';
@ -92,7 +89,7 @@ class AppRouter {
child: const RBACScreen(), child: const RBACScreen(),
); );
}); });
default: default:
return MaterialPageRoute(builder: (context) { return MaterialPageRoute(builder: (context) {
return Container(); return Container();

View File

@ -5,8 +5,8 @@ class Url {
String host() { String host() {
// return '192.168.10.183:3000'; // return '192.168.10.183:3000';
return 'agusandelnorte.gov.ph'; // return 'agusandelnorte.gov.ph';
// return "192.168.10.219:3000"; return "192.168.10.219:3000";
// return "192.168.10.241"; // return "192.168.10.241";
// return "192.168.10.221:3004"; // return "192.168.10.221:3004";
// return "playweb.agusandelnorte.gov.ph"; // return "playweb.agusandelnorte.gov.ph";
@ -15,7 +15,7 @@ class Url {
} }
String prefixHost() { String prefixHost() {
return "https"; return "https";
// return "http"; // return "http";
} }
@ -281,7 +281,7 @@ class Url {
} }
String agencies() { String agencies() {
return "/api/jobnet_app/agencies/"; return "/api/jobnet_app/agencies/";
} }
String postAgencies() { String postAgencies() {
@ -311,7 +311,8 @@ class Url {
String getRoleAssignment() { String getRoleAssignment() {
return "/api/account/auth/role_assignment/"; return "/api/account/auth/role_assignment/";
} }
String getPermissionAssignment(){
String getPermissionAssignment() {
return "/api/account/auth/permission_assignment/"; return "/api/account/auth/permission_assignment/";
} }
@ -347,7 +348,8 @@ class Url {
String getBarangays() { String getBarangays() {
return "/api/web_app/location/barangay/"; return "/api/web_app/location/barangay/";
} }
String getPurok(){
String getPurok() {
return "/api/web_app/location/purok/"; return "/api/web_app/location/purok/";
} }