Skip to content

Commit

Permalink
add delete user account
Browse files Browse the repository at this point in the history
  • Loading branch information
osamamohammed98 committed May 18, 2022
1 parent 2029cc5 commit 382babe
Show file tree
Hide file tree
Showing 8 changed files with 107 additions and 80 deletions.
8 changes: 4 additions & 4 deletions lib/feature/model/notification_data.dart
Original file line number Diff line number Diff line change
Expand Up @@ -33,12 +33,12 @@ class Result {
List<NotificationData>? data;

factory Result.fromJson(Map<String, dynamic> json) => Result(
pageTotle: json["pageTotle"],
data: List<NotificationData>.from(json["data"].map((x) => NotificationData.fromJson(x))),
pageTotle:json["pageTotle"] == null ? null: json["pageTotle"],
data:json["data"] == null ? null: List<NotificationData>.from(json["data"].map((x) => NotificationData.fromJson(x))),
);

Map<String, dynamic> toJson() => {
"pageTotle": pageTotle,
"data": List<dynamic>.from(data!.map((x) => x.toJson())),
"pageTotle": pageTotle == null ? null:pageTotle,
"data":data == null ? null: List<dynamic>.from(data!.map((x) => x.toJson())),
};
}
2 changes: 2 additions & 0 deletions lib/feature/view/views/auth_splash/auth_splash_view.dart
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ import 'dart:async';

import 'package:flutter/material.dart';
import 'package:get/get.dart';
import 'package:logger/logger.dart';
import 'package:sporti/feature/view/views/auth_login/auth_login_view.dart';
import 'package:sporti/feature/view/views/home_page/home_page_view.dart';
import 'package:sporti/util/app_dimen.dart';
Expand All @@ -28,6 +29,7 @@ class _SplashViewState extends State<SplashView>
void initState() {
WidgetsBinding.instance?.addPostFrameCallback((timeStamp) {
Timer(const Duration(seconds: 3), () {
Logger().i("${SharedPref.instance.getIsUserLogin()},${SharedPref.instance.getIsUserLogin() is String}");
if(SharedPref.instance.getIsUserLogin()){
Get.offAll(const HomePageView());
}else {
Expand Down
54 changes: 27 additions & 27 deletions lib/feature/view/views/notifications/notifications_view.dart
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ import 'package:get/get.dart';
import 'package:logger/logger.dart';
import 'package:sporti/fcm/app_fcm.dart';
import 'package:sporti/feature/view/appwidget/custome_text_view.dart';
import 'package:sporti/feature/view/views/home_page/widget/widget_home_tab/shimmer_your_work_widget.dart';
import 'package:sporti/feature/view/views/notifications/widget/notification_item.dart';
import 'package:sporti/util/app_color.dart';
import 'package:sporti/util/app_dimen.dart';
Expand Down Expand Up @@ -54,12 +55,12 @@ class NotificationsView extends StatelessWidget {
init: NotificationViewModel(),
initState: (state) {
WidgetsBinding.instance?.addPostFrameCallback((timeStamp) {
scrollController.addListener(scrollUp);
scrollController.addListener(state.controller!.loadMoreNotifications);
});
},
builder: (logic) {
if (logic.isLoading) {
return const PageShimmerWidget();
return const ShimmerSelectYourWorkWidget();
}
return Padding(
padding: const EdgeInsets.symmetric(
Expand All @@ -69,12 +70,7 @@ class NotificationsView extends StatelessWidget {
height: height,
child: Column(
children: [
(logic.isLoadingMore)
? SizedBox(
width: width,
height: 120,
child: const PageShimmerWidget())
: const SizedBox(),

Expanded(
child: ListView.separated(
controller: scrollController,
Expand All @@ -92,6 +88,12 @@ class NotificationsView extends StatelessWidget {
),
),
),
(logic.isLoadingMore)
? SizedBox(
width: width,
height: 120,
child: const PageShimmerWidget())
: const SizedBox(),
],
),
),
Expand All @@ -100,25 +102,23 @@ class NotificationsView extends StatelessWidget {
);
}

void scrollUp() async {
try {
if (scrollController.offset <=
scrollController.position.minScrollExtent &&
!scrollController.position.outOfRange) {
if (_notificationViewModel.page != _notificationViewModel.pagetotal &&
_notificationViewModel.page++ <=
_notificationViewModel.pagetotal!) {
_notificationViewModel.page = _notificationViewModel.page++;
_notificationViewModel.update();
await _notificationViewModel
.getAllNotifications(_notificationViewModel.page);
}
print("reach the top");
}
} on Exception catch (e) {
Logger().d("getAllNotifications(page)", e);
}
}
// void scrollUp() async {
// try {
// if (scrollController.offset <= scrollController.position.minScrollExtent && !scrollController.position.outOfRange) {
// if (_notificationViewModel.page != _notificationViewModel.pageTotal &&
// _notificationViewModel.page++ <=
// _notificationViewModel.pageTotal!) {
// _notificationViewModel.page = _notificationViewModel.page++;
// _notificationViewModel.update();
// await _notificationViewModel
// .getAllNotifications(_notificationViewModel.page);
// }
//
// }
// } on Exception catch (e) {
// Logger().d("getAllNotifications(page)", e);
// }
// }

onClickNotifyItem({NotificationViewModel? logic, int? index}) {
try {
Expand Down
14 changes: 7 additions & 7 deletions lib/feature/view/views/privacy_policy/privacy_policy_view.dart
Original file line number Diff line number Diff line change
Expand Up @@ -44,20 +44,20 @@ class PrivacyPolicyWidget extends StatelessWidget {
init: PrivacyPolicyViewModel(),
initState: (state) {
WidgetsBinding.instance!.addPostFrameCallback((timeStamp) {
state.controller!.getPrivacyAndTermsPages();
// state.controller!.getPrivacyAndTermsPages();
});
},
builder: (logic) {
return
Column(
children: [
ListTile(
title: HtmlWidget(
"${logic.privacyTitle}",
// _pref.getPolicyTitle(),
textStyle: themeData.textTheme.headline1
?.copyWith(color: AppColor.black),
),
// title: HtmlWidget(
// "${logic.privacyTitle}",
// // _pref.getPolicyTitle(),
// textStyle: themeData.textTheme.headline1
// ?.copyWith(color: AppColor.black),
// ),
contentPadding: const EdgeInsets.symmetric(
vertical: AppPadding.p14, horizontal: AppPadding.p14),
subtitle: HtmlWidget(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -41,18 +41,18 @@ class TermsConditionView extends StatelessWidget {
init: PrivacyPolicyViewModel(),
initState: (state) {
WidgetsBinding.instance!.addPostFrameCallback((timeStamp) {
state.controller!.getPrivacyAndTermsPages();
// state.controller!.getPrivacyAndTermsPages();
});
},
builder: (logic) {
return Column(
children: [
ListTile(
title: HtmlWidget(
"${logic.termsTitle}",
textStyle: themeData.textTheme.headline1
?.copyWith(color: AppColor.black),
),
// title: HtmlWidget(
// "${logic.termsTitle}",
// textStyle: themeData.textTheme.headline1
// ?.copyWith(color: AppColor.black),
// ),
contentPadding: const EdgeInsets.symmetric(
vertical: AppPadding.p14, horizontal: AppPadding.p14),
subtitle: HtmlWidget(
Expand Down
42 changes: 28 additions & 14 deletions lib/feature/viewmodel/notification_viewmodel.dart
Original file line number Diff line number Diff line change
Expand Up @@ -10,8 +10,8 @@ class NotificationViewModel extends GetxController {
bool isLoading = false;
bool isLoadingMore = false;
List<NotificationData> notificatiosDataList = [];
int page = 1;
int? pagetotal = 2;
int? page = 1;
int? pageTotal = 0;

@override
onInit() async {
Expand Down Expand Up @@ -41,28 +41,25 @@ class NotificationViewModel extends GetxController {
isLoadingMore = true;
}
update();
// if (page == this.page&&page++ < pagetotal) {
// page++;
// }
// update();
await NotificationsFeature.getInstance
.allNotifications(page)
.then((value) async {
if (value.data!.toList().isNotEmpty) {
Logger().d("value.data!.toList()", value.data!.toList());
if (value.data != null && value.data!.toList().isNotEmpty) {
// notificatiosDataList = value.data!.toList();
notificatiosDataList.addAll(value.data!.toList());
pagetotal = value.pageTotle;
print("notificatiosDataList pagetotal : " "$pagetotal");
print("notificatiosDataList.length");
print(notificatiosDataList.length);
for(var item in value.data!.toList()){
if(!notificatiosDataList.contains(item)){
notificatiosDataList.add(item);
}
}
// notificatiosDataList.addAll(value.data!.toList());
pageTotal = value.pageTotle;
isLoading = false;
isLoadingMore = false;
update();
}
}).catchError((onError) {
//handle error from value
snackError("getAllNotifications model catchError", onError.toString());
// snackError("getAllNotifications model catchError", onError.toString());
Logger().d(onError.toString());
isLoading = false;
isLoadingMore = false;
Expand All @@ -75,4 +72,21 @@ class NotificationViewModel extends GetxController {
update();
}
}



Future loadMoreNotifications() async {
isLoadingMore = true;
update();
if (page! <= pageTotal!) {
page = page! + 1;
// await getAllAnnouncement(
// pageIndexAllAnnouncement, pageSizeAllAnnouncement, "",
// isPagination: true);
await getAllNotifications(page);
await Future.delayed(const Duration(seconds: 0));
}
isLoadingMore = false;
update();
}
}
1 change: 1 addition & 0 deletions lib/main.dart
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ import 'package:country_code_picker/country_localizations.dart';
import 'package:firebase_core/firebase_core.dart';
import 'package:flutter/material.dart';
import 'package:get/get.dart';
import 'package:logger/logger.dart';
import 'package:responsive_framework/responsive_wrapper.dart';
import 'package:responsive_framework/utils/scroll_behavior.dart';
import 'package:sporti/fcm/app_fcm.dart';
Expand Down
54 changes: 32 additions & 22 deletions lib/util/sh_util.dart
Original file line number Diff line number Diff line change
@@ -1,12 +1,14 @@
import 'dart:convert';

import 'package:flutter/cupertino.dart';
import 'package:get/get.dart';
import 'package:get/utils.dart';

import 'package:logger/logger.dart';
import 'package:shared_preferences/shared_preferences.dart';
import 'package:sporti/feature/model/balance_data.dart';
import 'package:sporti/feature/model/user_data.dart';
import 'package:sporti/feature/viewmodel/privacyPolicy_viewmodel.dart';
import 'package:sporti/util/app_shaerd_data.dart';

import 'localization/localization_service.dart';
Expand All @@ -23,10 +25,10 @@ class SharedPref {
final String userDataKey = "userData";
final String userBalanceKey = "userBalanceKey";
final String loginKey = "login";
final String termsTitlekey = "login";
final String termsDetailskey = "login";
final String policyTitlekey = "login";
final String policyDetailskey = "login";
final String termsTitlekey = "termsTitlekey";
final String termsDetailskey = "termsDetailskey";
final String policyTitlekey = "policyTitlekey";
final String policyDetailskey = "policyDetailskey";

final String userNameKey = "userName";
final String passwordKey = "password";
Expand All @@ -36,31 +38,42 @@ class SharedPref {
init() async {
_prefs = await SharedPreferences?.getInstance();
}
setPolicyAndTermsString({String? termsTitle,String? termsDetails,String? policyTitle,String? policyDetails}) async {

setPolicyAndTermsString(
{String? termsTitle,
String? termsDetails,
String? policyTitle,
String? policyDetails}) async {
try {
_prefs?.setString(termsTitlekey, termsTitle??"");
_prefs?.setString(termsDetailskey, termsDetails??"");
_prefs?.setString(policyTitlekey, policyTitle??"");
_prefs?.setString(policyDetailskey, policyDetails??"");
_prefs?.setString(termsTitlekey, termsTitle ?? "");
_prefs?.setString(termsDetailskey, termsDetails ?? "");
_prefs?.setString(policyTitlekey, policyTitle ?? "");
_prefs?.setString(policyDetailskey, policyDetails ?? "");
} catch (e) {
printError(info: e.toString());
}
}

String getFCMToken() {
return _prefs!.getString(fcmKey) ?? "";
}

String getPolicyTitle() {
return _prefs!.getString(policyTitlekey) ?? "";
}
return _prefs!.getString(policyTitlekey) ?? "";
}

String getPolicyDetails() {
return _prefs!.getString(policyDetailskey) ?? "";
}
return _prefs!.getString(policyDetailskey) ?? "";
}

String getTermsTitle() {
return _prefs!.getString(termsTitlekey) ?? "";
}
return _prefs!.getString(termsTitlekey) ?? "";
}

String getTermsDetails() {
return _prefs!.getString(termsDetailskey) ?? "";
}
return _prefs!.getString(termsDetailskey) ?? "";
}

setFCMToken(String fcmToken) async {
try {
_prefs?.setString(fcmKey, fcmToken);
Expand All @@ -69,16 +82,13 @@ class SharedPref {
}
}

String getFCMToken() {
return _prefs!.getString(fcmKey) ?? "";
}

Future<void> setAppLang(String lang) async {
try {
if (!GetUtils.isNull(lang)) {
await _prefs?.setString(langKey, lang);
LocalizationService().changeLocale(lang);
loginAgain();
Get.put(PrivacyPolicyViewModel()).getPrivacyAndTermsPages();
}
} catch (e) {
printError(info: e.toString());
Expand Down Expand Up @@ -212,7 +222,7 @@ class SharedPref {
setUserDataVerify() {
try {
var userData = getUserData();
userData.isVerify =true;
userData.isVerify = true;
setUserData(jsonEncode(userData.toJson()));
} catch (e) {
Logger().e(e);
Expand Down

0 comments on commit 382babe

Please sign in to comment.