217 lines
7.3 KiB
Dart
217 lines
7.3 KiB
Dart
import 'package:flutter/cupertino.dart';
|
|
import 'package:flutter/material.dart';
|
|
import 'package:flutter_screenutil/flutter_screenutil.dart';
|
|
import 'package:get/get.dart';
|
|
import 'package:regroup/Common/CommonWidget.dart';
|
|
import 'package:regroup/Common/base_manager.dart';
|
|
import 'package:regroup/Main_Screens/ProfileTab/EditProfile/ViewModel/EditProfileApi.dart';
|
|
import 'package:regroup/Main_Screens/ProfileTab/view_model/profilePostmethod.dart';
|
|
|
|
import 'package:regroup/Utils/Common/CommonAppbar.dart';
|
|
import 'package:regroup/Utils/Common/sized_box.dart';
|
|
import 'package:regroup/Utils/dialogs.dart';
|
|
import 'package:regroup/Utils/texts.dart';
|
|
import 'package:regroup/resources/routes/route_name.dart';
|
|
import 'package:shared_preferences/shared_preferences.dart';
|
|
|
|
class AccountSettings extends StatefulWidget {
|
|
const AccountSettings({super.key});
|
|
|
|
@override
|
|
State<AccountSettings> createState() => _AccountSettingsState();
|
|
}
|
|
|
|
class _AccountSettingsState extends State<AccountSettings> {
|
|
// bool swichvalue = false;
|
|
|
|
String? accountTypeValue;
|
|
String? accounTypeLogin;
|
|
|
|
@override
|
|
void initState() {
|
|
setValues();
|
|
super.initState();
|
|
}
|
|
|
|
setValues() async {
|
|
SharedPreferences prefs = await SharedPreferences.getInstance();
|
|
// Update state variables and trigger UI update with setState
|
|
setState(() {
|
|
accounTypeLogin = prefs.getString('accountTypefromLogin');
|
|
print('account type login is $accounTypeLogin');
|
|
accountTypeValue = prefs.getString('accountTypeValue');
|
|
// print('account type value is $accountTypeValue');
|
|
});
|
|
}
|
|
|
|
Future<void> UploadData() async {
|
|
print("upload data called");
|
|
SharedPreferences prefs = await SharedPreferences.getInstance();
|
|
|
|
int? accountype;
|
|
if (accountvisibility == false) {
|
|
accountype = 0;
|
|
} else if (accountvisibility == true) {
|
|
accountype = 1;
|
|
}
|
|
Map<String, dynamic> updata = {
|
|
"is_account_visibility": accountype,
|
|
};
|
|
|
|
final data = await Profilepostmethod().postAccountvisibility(updata);
|
|
|
|
if (data.status == ResponseStatus.SUCCESS) {
|
|
String? accountype;
|
|
|
|
accountype = prefs.getString('accountTypefromLogin');
|
|
|
|
if (accountype == "1") {
|
|
EditProfileApi().getEditProfileIndividual();
|
|
} else if (accountype == "2") {
|
|
EditProfileApi().getEditProfileBusiness();
|
|
}
|
|
|
|
return utils.showToast(data.message);
|
|
} else {
|
|
return utils.showToast(data.message);
|
|
}
|
|
}
|
|
|
|
@override
|
|
Widget build(BuildContext context) {
|
|
return Scaffold(
|
|
// key: _scaffoldKey1,
|
|
resizeToAvoidBottomInset: false,
|
|
backgroundColor: Color(0xFF222935),
|
|
extendBody: true,
|
|
appBar: CommonAppbar(
|
|
titleTxt: "Account settings",
|
|
),
|
|
body: Stack(children: [
|
|
Container(
|
|
decoration: const BoxDecoration(
|
|
image: DecorationImage(
|
|
image: AssetImage(
|
|
"assets/images/png/Ellipse 1496.png",
|
|
),
|
|
fit: BoxFit.fill)),
|
|
),
|
|
SingleChildScrollView(
|
|
child: Column(
|
|
crossAxisAlignment: CrossAxisAlignment.start,
|
|
children: [
|
|
sizedBoxHeight(20.h),
|
|
Padding(
|
|
padding: EdgeInsets.symmetric(horizontal: 16.w),
|
|
child: text18w700_FCFCFC("Sign in & security"),
|
|
),
|
|
sizedBoxHeight(20.h),
|
|
accounTypeLogin == '1'
|
|
? Column(
|
|
children: [
|
|
Padding(
|
|
padding: EdgeInsets.symmetric(
|
|
horizontal: 16.w, vertical: 20.h),
|
|
child: Row(children: [
|
|
Image.asset(
|
|
"assets/images/png/eyeIcon.png",
|
|
height: 21.h,
|
|
width: 21.w,
|
|
),
|
|
sizedBoxWidth(12.w),
|
|
text16w400_FCFCFC("Account visibility"),
|
|
Spacer(),
|
|
Transform.scale(
|
|
scale: 0.9,
|
|
child: CupertinoSwitch(
|
|
value: accountvisibility,
|
|
trackColor: Colors.white.withOpacity(0.4),
|
|
activeColor: Color(0xFF34C759),
|
|
onChanged: (bool value) {
|
|
setState(() {
|
|
accountvisibility = value;
|
|
UploadData();
|
|
|
|
// swichvalue = value ?? false;
|
|
});
|
|
}))
|
|
]),
|
|
),
|
|
commonDivider(),
|
|
],
|
|
)
|
|
: SizedBox(),
|
|
GestureDetector(
|
|
onTap: () {
|
|
Get.toNamed(RouteName.changepassword);
|
|
},
|
|
child: rowTile(
|
|
imagePath: "assets/images/png/BlackPass.png",
|
|
text: "Change password"),
|
|
),
|
|
commonDivider(),
|
|
GestureDetector(
|
|
onTap: () {
|
|
Get.toNamed(RouteName.accaountsession);
|
|
},
|
|
child: rowTile(
|
|
imagePath: "assets/images/png/clock.png",
|
|
text: "Account sessions"),
|
|
),
|
|
commonDivider(),
|
|
GestureDetector(
|
|
onTap: () {
|
|
Get.toNamed(RouteName.blockedusers);
|
|
},
|
|
child: rowTile(
|
|
imagePath: "assets/images/png/blocked.png",
|
|
text: "Blocked users"),
|
|
),
|
|
commonDivider(),
|
|
GestureDetector(
|
|
onTap: () {
|
|
Get.toNamed(RouteName.deleteaccount);
|
|
},
|
|
child: Padding(
|
|
padding:
|
|
EdgeInsets.symmetric(horizontal: 16.w, vertical: 20.h),
|
|
child: Row(children: [
|
|
Image.asset(
|
|
"assets/images/png/deleteIcon (2).png",
|
|
height: 21.h,
|
|
width: 21.w,
|
|
),
|
|
sizedBoxWidth(12.w),
|
|
text16w400_FF0000("Delete account"),
|
|
]),
|
|
),
|
|
)
|
|
]))
|
|
]));
|
|
}
|
|
|
|
Widget rowTile({
|
|
required String imagePath,
|
|
required String text,
|
|
}) {
|
|
return Padding(
|
|
padding: EdgeInsets.symmetric(horizontal: 16.w, vertical: 20.h),
|
|
child: Row(children: [
|
|
Image.asset(
|
|
imagePath,
|
|
height: 21.h,
|
|
width: 21.w,
|
|
),
|
|
sizedBoxWidth(12.w),
|
|
text16w400_FCFCFC(text),
|
|
Spacer(),
|
|
Icon(
|
|
Icons.arrow_forward_ios,
|
|
color: Colors.white,
|
|
size: 20,
|
|
)
|
|
]),
|
|
);
|
|
}
|
|
}
|