|
|
@@ -22,6 +22,7 @@ import 'package:telnow_mobile_new/src/utils/C.dart';
|
|
|
import 'package:telnow_mobile_new/src/utils/U.dart';
|
|
|
import 'package:telnow_mobile_new/src/utils/cache_manager.dart';
|
|
|
import 'package:telnow_mobile_new/src/utils/provider.dart';
|
|
|
+import 'package:telnow_mobile_new/src/utils/ui_service.dart';
|
|
|
import 'package:url_launcher/url_launcher.dart';
|
|
|
|
|
|
class MobHomePage extends StatefulWidget {
|
|
|
@@ -33,14 +34,18 @@ class MobHomePage extends StatefulWidget {
|
|
|
|
|
|
class _MobHomePageState extends State<MobHomePage> with WidgetsBindingObserver {
|
|
|
final HomeFunction homeFunc = HomeFunction();
|
|
|
+
|
|
|
final SharedPreferencesManager sharedPreferencesManager = locator<SharedPreferencesManager>();
|
|
|
bool _timeLimit = false;
|
|
|
String _localeIndex = 'id';
|
|
|
|
|
|
+ late final ServiceModule serviceModule = homeFunc.serviceModule;
|
|
|
+ late final UserModule userModule = homeFunc.userModule;
|
|
|
+
|
|
|
@override
|
|
|
void initState() {
|
|
|
- Provider.of<ServiceModule>(context, listen: false).reset();
|
|
|
- Provider.of<UserModule>(context, listen: false).reset();
|
|
|
+ // serviceModule.reset();
|
|
|
+ // userModule.reset();
|
|
|
|
|
|
WidgetsBinding.instance.addPostFrameCallback((_) {
|
|
|
Future.delayed(Duration(seconds: 1), (){
|
|
|
@@ -74,8 +79,27 @@ class _MobHomePageState extends State<MobHomePage> with WidgetsBindingObserver {
|
|
|
|
|
|
@override
|
|
|
Widget build(BuildContext context) {
|
|
|
+ final UserModule userModuleListen = Provider.of<UserModule>(context);
|
|
|
+ final ServiceModule serviceModuleListen = Provider.of<ServiceModule>(context);
|
|
|
+ String name = userModuleListen.user()['name'] ?? '';
|
|
|
+ String searchText = 'searchAsk'.tr();
|
|
|
+ bool showTopMenu = false;
|
|
|
+
|
|
|
+ if(userModuleListen.user()['guestName'] != null && userModuleListen.user()['guestName'] != ''){
|
|
|
+ name = '$name ${userModuleListen.user()['guestName']}';
|
|
|
+ }
|
|
|
+
|
|
|
+ if(userModuleListen.profile()['searchText'] != null && userModuleListen.profile()['searchText'][context.locale.toString()] != ''){
|
|
|
+ searchText = userModuleListen.profile()['searchText'][context.locale.toString()];
|
|
|
+ }
|
|
|
+
|
|
|
+ if(userModuleListen.profile()['topMenu'] != null && userModuleListen.profile()['topMenu']['show'] == true) {
|
|
|
+ showTopMenu = true;
|
|
|
+ }
|
|
|
+
|
|
|
_localeIndex = U.newServerVersion(1754624839) ? U.getLangIndex(context.locale.toString()) : context.locale.toString();
|
|
|
- return Provider.of<UserModule>(context).user().isNotEmpty?Scaffold(
|
|
|
+
|
|
|
+ return userModuleListen.user().isNotEmpty ? Scaffold(
|
|
|
backgroundColor: backgroundColor,
|
|
|
body: Column(
|
|
|
children: [
|
|
|
@@ -90,7 +114,7 @@ class _MobHomePageState extends State<MobHomePage> with WidgetsBindingObserver {
|
|
|
Row(
|
|
|
mainAxisAlignment: MainAxisAlignment.spaceBetween,
|
|
|
children: [
|
|
|
- Text('${Provider.of<UserModule>(context).user()['name']}${(Provider.of<UserModule>(context).user()['guestName'] != null && Provider.of<UserModule>(context).user()['guestName'] != '' ? ' - ${Provider.of<UserModule>(context).user()['guestName']}' : '')}', style: TextStyle(color: Colors.white, fontSize: 18), overflow: TextOverflow.ellipsis),
|
|
|
+ Text(name, style: TextStyle(color: Colors.white, fontSize: 18), overflow: TextOverflow.ellipsis),
|
|
|
Row(
|
|
|
children: [
|
|
|
//TODO: tambah pengecekan server version disini
|
|
|
@@ -98,42 +122,35 @@ class _MobHomePageState extends State<MobHomePage> with WidgetsBindingObserver {
|
|
|
future: U.isCompatibleWith(VersionKey.multiBahasa),
|
|
|
builder: (context, snapshot) {
|
|
|
if (!snapshot.hasData) {
|
|
|
- return SizedBox(); // or a loading spinner
|
|
|
+ return SizedBox();
|
|
|
}
|
|
|
|
|
|
final isCompatible = snapshot.data!;
|
|
|
- final hasContactCenter = Provider.of<ServiceModule>(context, listen: false)
|
|
|
- .contactCenter()
|
|
|
- .toString()
|
|
|
- .isNotEmpty;
|
|
|
+ final hasContactCenter = serviceModule.contactCenter().toString().isNotEmpty;
|
|
|
|
|
|
if (isCompatible && hasContactCenter) {
|
|
|
return GestureDetector(
|
|
|
- onTap: () => launchUrl(Uri.parse(Provider.of<ServiceModule>(context, listen: false).contactCenter().toString())),
|
|
|
+ onTap: () => launchUrl(Uri.parse(serviceModule.contactCenter().toString())),
|
|
|
child: U.iconsax('phone-number', color: Colors.white, size: 26.0)
|
|
|
- ); // replace with the widget you want to show
|
|
|
+ );
|
|
|
} else {
|
|
|
return SizedBox(); // or nothing
|
|
|
}
|
|
|
},
|
|
|
),
|
|
|
- // U.isCompatibleWith(VersionKey.multiBahasa) && Provider.of<ServiceModule>(context, listen: false).contactCenter().toString() != '' ? GestureDetector(
|
|
|
- // onTap: () => launchUrl(Uri.parse(Provider.of<ServiceModule>(context, listen: false).contactCenter().toString())),
|
|
|
- // child: U.iconsax('phone-number', color: Colors.white, size: 26.0)
|
|
|
- // ):SizedBox(),
|
|
|
SizedBox(width: 8),
|
|
|
GestureDetector(
|
|
|
child: Stack(
|
|
|
alignment: Alignment.topRight,
|
|
|
children: [
|
|
|
U.iconsax('sms-notification', color: Colors.white, size: 32.0),
|
|
|
- Provider.of<ServiceModule>(context).unreadMessage() ? Container(
|
|
|
+ serviceModuleListen.unreadMessage() ? Container(
|
|
|
width: 13, height: 13, margin: EdgeInsets.only(top: 1.3),
|
|
|
decoration: BoxDecoration(color: Colors.red, borderRadius: BorderRadius.all(Radius.circular(50))),
|
|
|
):Container()
|
|
|
],
|
|
|
),
|
|
|
- onTap: ()=>navigateTo(context, MobMessageListPage(Provider.of<UserModule>(context, listen: false).user())).then((_){
|
|
|
+ onTap: () => navigateTo(context, MobMessageListPage(userModule.user())).then((_){
|
|
|
homeFunc.getUnreadMessages(context);
|
|
|
}),
|
|
|
)
|
|
|
@@ -141,7 +158,9 @@ class _MobHomePageState extends State<MobHomePage> with WidgetsBindingObserver {
|
|
|
)
|
|
|
],
|
|
|
),
|
|
|
- Provider.of<UserModule>(context).profile()['greeting'][context.locale.toString()] != null ? Text(Provider.of<UserModule>(context).profile()['greeting'][context.locale.toString()], style: TextStyle(color: Colors.white, fontSize: 14), overflow: TextOverflow.ellipsis) : Container(),
|
|
|
+ if(userModuleListen.profile()['greeting'] != null && userModuleListen.profile()['greeting'][context.locale.toString()] != null)
|
|
|
+ Text(userModuleListen.profile()['greeting'][context.locale.toString()], style: TextStyle(color: Colors.white, fontSize: 14), overflow: TextOverflow.ellipsis),
|
|
|
+ // : Container(),
|
|
|
SizedBox(height: 8),
|
|
|
Row(
|
|
|
children: [
|
|
|
@@ -157,11 +176,11 @@ class _MobHomePageState extends State<MobHomePage> with WidgetsBindingObserver {
|
|
|
children: [
|
|
|
U.iconsax('search-normal-1', color: textColor),
|
|
|
SizedBox(width: 13),
|
|
|
- Expanded(child: Text(Provider.of<UserModule>(context).profile()['searchText'][context.locale.toString()] ?? 'searchAsk'.tr(), style: TextStyle(color: textColor.withValues(alpha: 0.5), fontSize: 14), overflow: TextOverflow.ellipsis))
|
|
|
+ Expanded(child: Text(searchText, style: TextStyle(color: textColor.withValues(alpha: 0.5), fontSize: 14), overflow: TextOverflow.ellipsis))
|
|
|
],
|
|
|
),
|
|
|
),
|
|
|
- onTap: () => navigateTo(context, MobReqSelectPage(user: Provider.of<UserModule>(context, listen: false).user(), title: 'search'.tr(), scope: Provider.of<ServiceModule>(context, listen: false).scoopeValue(), placeholder: Provider.of<UserModule>(context, listen: false).profile()['searchText'][context.locale.toString()] ?? 'searchAsk'.tr())).then((val){
|
|
|
+ onTap: () => navigateTo(context, MobReqSelectPage(user: userModule.user(), title: 'search'.tr(), scope: serviceModule.scoopeValue(), placeholder: userModule.profile()['searchText'][context.locale.toString()] ?? 'searchAsk'.tr())).then((val){
|
|
|
val = val??true;
|
|
|
if(val) homeFunc.getFrequentlyRequested();
|
|
|
}),
|
|
|
@@ -197,20 +216,20 @@ class _MobHomePageState extends State<MobHomePage> with WidgetsBindingObserver {
|
|
|
GestureDetector(
|
|
|
child: Container(
|
|
|
padding: EdgeInsets.fromLTRB(16, 4, 16, 4),
|
|
|
+ decoration: BoxDecoration(
|
|
|
+ color: primaryColor.withValues(alpha: 0.1),
|
|
|
+ borderRadius: BorderRadius.all(Radius.circular(50))
|
|
|
+ ),
|
|
|
child: Row(
|
|
|
children: [
|
|
|
- Text(Provider.of<ServiceModule>(context).scoopeName(), style: TextStyle(color: primaryColor, fontSize: 14)),
|
|
|
+ Text(serviceModuleListen.scoopeName(), style: TextStyle(color: primaryColor, fontSize: 14)),
|
|
|
SizedBox(width: 8),
|
|
|
U.iconsax('arrow-down-1', color: primaryColor, size: 14),
|
|
|
],
|
|
|
),
|
|
|
- decoration: BoxDecoration(
|
|
|
- color: primaryColor.withValues(alpha: 0.1),
|
|
|
- borderRadius: BorderRadius.all(Radius.circular(50))
|
|
|
- ),
|
|
|
),
|
|
|
onTap: (){
|
|
|
- if(Provider.of<ServiceModule>(context, listen: false).scoope().isNotEmpty){
|
|
|
+ if(serviceModule.scoope().isNotEmpty){
|
|
|
showModalBottomSheet<void>(
|
|
|
context: context,
|
|
|
backgroundColor: Colors.white,
|
|
|
@@ -226,7 +245,7 @@ class _MobHomePageState extends State<MobHomePage> with WidgetsBindingObserver {
|
|
|
divider(),
|
|
|
SizedBox(height: 16),
|
|
|
Column(
|
|
|
- children: List.generate(Provider.of<ServiceModule>(context).getScoopeLength(), (i){
|
|
|
+ children: List.generate(serviceModuleListen.getScoopeLength(), (i){
|
|
|
return GestureDetector(
|
|
|
child: Container(
|
|
|
color: Colors.white,
|
|
|
@@ -234,25 +253,27 @@ class _MobHomePageState extends State<MobHomePage> with WidgetsBindingObserver {
|
|
|
child: Row(
|
|
|
mainAxisAlignment: MainAxisAlignment.spaceBetween,
|
|
|
children: [
|
|
|
- Text(Provider.of<ServiceModule>(context).scoope()[i]['value'], style: TextStyle(color: textColor, fontSize: 14)),
|
|
|
- Icon(Provider.of<ServiceModule>(context).checkScoope(Provider.of<ServiceModule>(context).scoope()[i]['key'])?Icons.radio_button_checked:Icons.radio_button_off, color: Provider.of<ServiceModule>(context).checkScoope(Provider.of<ServiceModule>(context).scoope()[i]['key'])?primaryColor:Colors.black45, size: 22),
|
|
|
+ Text(serviceModuleListen.scoope()[i]['value'], style: TextStyle(color: textColor, fontSize: 14)),
|
|
|
+ Icon(serviceModuleListen.checkScoope(serviceModuleListen.scoope()[i]['key'])?Icons.radio_button_checked:Icons.radio_button_off, color: serviceModuleListen.checkScoope(serviceModuleListen.scoope()[i]['key'])?primaryColor:Colors.black45, size: 22),
|
|
|
],
|
|
|
),
|
|
|
),
|
|
|
onTap: () async{
|
|
|
- await sharedPreferencesManager.putString(SharedPreferencesManager.keyScoope, Provider.of<ServiceModule>(context, listen: false).scoope()[i]['key']);
|
|
|
- Provider.of<ServiceModule>(context, listen: false).setScoopeValue(Provider.of<ServiceModule>(context, listen: false).scoope()[i]['key']);
|
|
|
- Provider.of<ServiceModule>(context, listen: false).setScoopeName(Provider.of<ServiceModule>(context, listen: false).scoope()[i]['value']);
|
|
|
- Navigator.of(contexts).pop();
|
|
|
+ final nav = Navigator.of(contexts);
|
|
|
+
|
|
|
+ await sharedPreferencesManager.putString(SharedPreferencesManager.keyScoope, serviceModule.scoope()[i]['key']);
|
|
|
+ serviceModule.setScoopeValue(serviceModule.scoope()[i]['key']);
|
|
|
+ serviceModule.setScoopeName(serviceModule.scoope()[i]['value']);
|
|
|
+ nav.pop();
|
|
|
|
|
|
- var profile = Provider.of<UserModule>(context, listen: false).profile();
|
|
|
+ var profile = userModule.profile();
|
|
|
if(profile['topMenu']['show'] != null && profile['topMenu']['show'] == true) {
|
|
|
if(U.newServerVersion(1709864293)){
|
|
|
- homeFunc.getTopMenuNew(context);
|
|
|
+ homeFunc.getTopMenuNew();
|
|
|
}
|
|
|
else{
|
|
|
- homeFunc.getTopMenu(context);
|
|
|
- homeFunc.getReqGroup(context);
|
|
|
+ homeFunc.getTopMenu();
|
|
|
+ homeFunc.getReqGroup();
|
|
|
}
|
|
|
}
|
|
|
if(profile['specialOffer'] != null && profile['specialOffer']['show'] == true) homeFunc.getSpecialOffer(context);
|
|
|
@@ -275,7 +296,7 @@ class _MobHomePageState extends State<MobHomePage> with WidgetsBindingObserver {
|
|
|
],
|
|
|
),
|
|
|
),
|
|
|
- Provider.of<UserModule>(context).profile()['topMenu']['show'] != null && Provider.of<UserModule>(context).profile()['topMenu']['show'] == true ? Container(
|
|
|
+ if(showTopMenu) Container(
|
|
|
margin: EdgeInsets.symmetric(horizontal: 16),
|
|
|
child: Provider.of<ServiceModule>(context).topMenu() != null && Provider.of<ServiceModule>(context).reqGroup() != null?Column(
|
|
|
children: List.generate(((Provider.of<ServiceModule>(context).topMenu()!.length+1)/4).ceil(), (i){
|
|
|
@@ -327,7 +348,7 @@ class _MobHomePageState extends State<MobHomePage> with WidgetsBindingObserver {
|
|
|
);
|
|
|
}),
|
|
|
):shimmerTopMenu(context),
|
|
|
- ):Container(),
|
|
|
+ ),
|
|
|
|
|
|
Provider.of<UserModule>(context).profile()['specialOffer'] != null && Provider.of<UserModule>(context).profile()['specialOffer']['show'] == true ? Container(
|
|
|
margin: EdgeInsets.only(top: 36),
|
|
|
@@ -482,12 +503,12 @@ class _MobHomePageState extends State<MobHomePage> with WidgetsBindingObserver {
|
|
|
decoration: BoxDecoration(
|
|
|
color: textColor.withValues(alpha: 0.1),
|
|
|
borderRadius: BorderRadius.all(Radius.circular(12)),
|
|
|
- image: Provider.of<ServiceModule>(context).banner()[i]['image'] != null ? DecorationImage(
|
|
|
- image: CachedNetworkImageProvider(Provider.of<ServiceModule>(context).banner()[i]['image']+'?bridge-cache=true', cacheManager: CacheManager(CacheMan.config(Provider.of<ServiceModule>(context).banner()[i]['image']))),
|
|
|
+ image: serviceModule.banner()[i]['image'] != null ? DecorationImage(
|
|
|
+ image: CachedNetworkImageProvider(Provider.of<ServiceModule>(context).banner()[i]['image']+'?bridge-cache=true', cacheManager: CacheManager(CacheMan.config(serviceModule.banner()[i]['image']))),
|
|
|
fit: BoxFit.cover,
|
|
|
):null,
|
|
|
),
|
|
|
- child: Provider.of<ServiceModule>(context).banner()[i]['image'] != null ? null : Center(child: Text("noImage".tr(), style: TextStyle(fontStyle: FontStyle.italic, color: Colors.black38), textAlign: TextAlign.center)),
|
|
|
+ child: serviceModule.banner()[i]['image'] != null ? null : Center(child: Text("noImage".tr(), style: TextStyle(fontStyle: FontStyle.italic, color: Colors.black38), textAlign: TextAlign.center)),
|
|
|
),
|
|
|
),
|
|
|
Container(
|