io api settings api
This commit is contained in:
@@ -1,6 +1,12 @@
|
||||
import 'dart:io';
|
||||
|
||||
import 'package:bloc/bloc.dart';
|
||||
import 'package:tanami_app/core/utils/secure/secure_storage_service.dart';
|
||||
|
||||
import '../../../../Api_Helper/base_manager.dart';
|
||||
import '../../../../core/utils/device_info/device_info_data.dart';
|
||||
import '../../../../features/MainScreens/Settings/domain/repository/settings_api.dart';
|
||||
import '../../../../features/register/Repository/RegisterApi.dart';
|
||||
import 'toggle_event.dart';
|
||||
import 'toggle_state.dart';
|
||||
|
||||
@@ -16,11 +22,75 @@ class ToggleBloc extends Bloc<ToggleEvent, ToggleState> {
|
||||
|
||||
void _onToggleSwitch(ToggleSwitch event, Emitter<ToggleState> emit) async {
|
||||
if (state is ToggleOn) {
|
||||
emit(ToggleOff());
|
||||
await secureStorageService.write(type, 'off');
|
||||
if (type == "biometric") {
|
||||
emit(ToggleOff());
|
||||
|
||||
Map<String, dynamic> biometricdata = {
|
||||
"code": await secureStorageService.read("temp_token"),
|
||||
"is_2FA_on": false,
|
||||
"deviceId": await DeviceInfoData().getDeviceId(),
|
||||
"biometric_type": Platform.isIOS ? "face" : "fingerprint"
|
||||
};
|
||||
|
||||
ResponseData response =
|
||||
await RegisterAPIService().BiometricUpdate(biometricdata);
|
||||
if (response.status == ResponseStatus.SUCCESS) {
|
||||
await secureStorageService.write(type, 'off');
|
||||
await secureStorageService.write("biometric", 'of');
|
||||
} else {
|
||||
emit(ToggleOn());
|
||||
await secureStorageService.write(type, 'on');
|
||||
}
|
||||
} else if (type == "notification") {
|
||||
emit(ToggleOff());
|
||||
|
||||
ResponseData response = await SettingsApi().updateNotification();
|
||||
if (response.status == ResponseStatus.SUCCESS) {
|
||||
await secureStorageService.write(type, 'off');
|
||||
await secureStorageService.write("notification", 'of');
|
||||
} else {
|
||||
emit(ToggleOn());
|
||||
await secureStorageService.write(type, 'on');
|
||||
}
|
||||
} else {
|
||||
emit(ToggleOff());
|
||||
await secureStorageService.write(type, 'off');
|
||||
}
|
||||
} else {
|
||||
emit(ToggleOn());
|
||||
await secureStorageService.write(type, 'on');
|
||||
if (type == "biometric") {
|
||||
emit(ToggleOn());
|
||||
|
||||
Map<String, dynamic> biometricdata = {
|
||||
"code": await secureStorageService.read("temp_token"),
|
||||
"is_2FA_on": true,
|
||||
"deviceId": await DeviceInfoData().getDeviceId(),
|
||||
"biometric_type": Platform.isIOS ? "face" : "fingerprint"
|
||||
};
|
||||
|
||||
ResponseData response =
|
||||
await RegisterAPIService().BiometricUpdate(biometricdata);
|
||||
if (response.status == ResponseStatus.SUCCESS) {
|
||||
await secureStorageService.write("biometric", 'on');
|
||||
await secureStorageService.write(type, 'on');
|
||||
} else {
|
||||
emit(ToggleOff());
|
||||
await secureStorageService.write(type, 'off');
|
||||
}
|
||||
} else if (type == "notification") {
|
||||
emit(ToggleOn());
|
||||
|
||||
ResponseData response = await SettingsApi().updateNotification();
|
||||
if (response.status == ResponseStatus.SUCCESS) {
|
||||
await secureStorageService.write(type, 'on');
|
||||
await secureStorageService.write("notification", 'on');
|
||||
} else {
|
||||
emit(ToggleOff());
|
||||
await secureStorageService.write(type, 'off');
|
||||
}
|
||||
} else {
|
||||
emit(ToggleOn());
|
||||
await secureStorageService.write(type, 'on');
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
110
lib/shared/components/forgot_password_log_out_dialog.dart
Normal file
110
lib/shared/components/forgot_password_log_out_dialog.dart
Normal file
@@ -0,0 +1,110 @@
|
||||
import 'package:flutter/material.dart';
|
||||
import 'package:flutter_bloc/flutter_bloc.dart';
|
||||
import 'package:flutter_screenutil/flutter_screenutil.dart';
|
||||
import 'package:gap/gap.dart';
|
||||
|
||||
import '../../core/routes/route_name.dart';
|
||||
import '../../core/routes/routes.dart';
|
||||
import '../../core/styles/app_color.dart';
|
||||
import '../../core/styles/app_text.dart';
|
||||
import '../../core/utils/language/localizations_delegate.dart';
|
||||
import '../../core/utils/secure/secure_storage_service.dart';
|
||||
import 'bloc/bottom_nav_bar/bottom_navigation_bloc.dart';
|
||||
import 'bloc/bottom_nav_bar/bottom_navigation_event.dart';
|
||||
import 'text_widget.dart';
|
||||
|
||||
forgotPasswordlogoutdialog(context) {
|
||||
var localizations = AppLocalizations.of(context);
|
||||
SecureStorageService secureStorageService = SecureStorageService();
|
||||
return showDialog(
|
||||
context: context,
|
||||
builder: (context) => Column(
|
||||
mainAxisAlignment: MainAxisAlignment.center,
|
||||
children: [
|
||||
AlertDialog(
|
||||
insetPadding: const EdgeInsets.symmetric(horizontal: 16),
|
||||
backgroundColor: AppColor.plainWhite,
|
||||
shape: const RoundedRectangleBorder(
|
||||
borderRadius: BorderRadius.all(Radius.circular(20)),
|
||||
side: BorderSide(
|
||||
color: AppColor.plainWhite,
|
||||
),
|
||||
),
|
||||
content: Column(
|
||||
mainAxisSize: MainAxisSize.min,
|
||||
children: [
|
||||
TextWidget().text17W700(
|
||||
localizations.translate(AppText.notificationText),
|
||||
clr: AppColor.plainBlack),
|
||||
const Gap(25),
|
||||
Padding(
|
||||
padding: const EdgeInsets.symmetric(
|
||||
horizontal: 25,
|
||||
),
|
||||
child: TextWidget().text15W500(
|
||||
localizations
|
||||
.translate(AppText.toRestorePasswordYouWillBeLoggedOut),
|
||||
clr: AppColor.hintTextColor,
|
||||
),
|
||||
),
|
||||
const Gap(30),
|
||||
Row(
|
||||
mainAxisAlignment: MainAxisAlignment.spaceAround,
|
||||
children: [
|
||||
GestureDetector(
|
||||
onTap: () {
|
||||
goRouter.pop();
|
||||
},
|
||||
child: Container(
|
||||
height: 48.h,
|
||||
width: 140.w,
|
||||
decoration: BoxDecoration(
|
||||
border: Border.all(
|
||||
color: AppColor.primaryColor2,
|
||||
),
|
||||
borderRadius: BorderRadius.circular(10.h),
|
||||
color: AppColor.plainWhite),
|
||||
child: Center(
|
||||
child: TextWidget().text18W700(
|
||||
localizations.translate(AppText.declineText),
|
||||
clr: AppColor.primaryColor2,
|
||||
),
|
||||
),
|
||||
),
|
||||
),
|
||||
Gap(28.w),
|
||||
GestureDetector(
|
||||
onTap: () async {
|
||||
context.read<BottomNavigationBloc>().add(TabChanged(2));
|
||||
await secureStorageService.write('isLoginedIn', "false");
|
||||
await secureStorageService.write('accesstoken', '');
|
||||
await secureStorageService.write('refreshtoken', '');
|
||||
await secureStorageService.write('temp_token', '');
|
||||
|
||||
goRouter.goNamed(RouteName.loginScreen, pathParameters: {
|
||||
"fromScreen": "registerStep",
|
||||
});
|
||||
},
|
||||
child: Container(
|
||||
height: 48.h,
|
||||
width: 140.w,
|
||||
decoration: BoxDecoration(
|
||||
borderRadius: BorderRadius.circular(10.h),
|
||||
color: AppColor.primaryColor),
|
||||
child: Center(
|
||||
child: TextWidget().text18W700(
|
||||
localizations.translate(AppText.allowText),
|
||||
clr: AppColor.plainWhite,
|
||||
),
|
||||
),
|
||||
),
|
||||
),
|
||||
],
|
||||
),
|
||||
],
|
||||
),
|
||||
),
|
||||
],
|
||||
),
|
||||
);
|
||||
}
|
||||
@@ -91,6 +91,7 @@ buildprofilelogoutdialog(context) {
|
||||
await secureStorageService.write('isLoginedIn', "false");
|
||||
await secureStorageService.write('accesstoken', '');
|
||||
await secureStorageService.write('refreshtoken', '');
|
||||
await secureStorageService.write('temp_token', '');
|
||||
|
||||
goRouter.goNamed(RouteName.loginScreen, pathParameters: {
|
||||
"fromScreen": "registerStep",
|
||||
|
||||
@@ -1,8 +1,11 @@
|
||||
import 'dart:io';
|
||||
|
||||
import 'package:flutter/material.dart';
|
||||
import 'package:flutter_screenutil/flutter_screenutil.dart';
|
||||
import 'package:gap/gap.dart';
|
||||
import 'package:tanami_app/Api_Helper/base_manager.dart';
|
||||
import 'package:tanami_app/core/styles/app_color.dart';
|
||||
import 'package:tanami_app/core/utils/device_info/device_info_data.dart';
|
||||
import 'package:tanami_app/shared/components/loader.dart';
|
||||
|
||||
import '../../core/routes/route_name.dart';
|
||||
@@ -85,12 +88,30 @@ permissionDialog(
|
||||
mainAxisAlignment: MainAxisAlignment.spaceAround,
|
||||
children: [
|
||||
GestureDetector(
|
||||
onTap: () {
|
||||
goRouter.pop();
|
||||
onTap: () async {
|
||||
Loader.loader(context);
|
||||
Map<String, dynamic> biometricdata = {
|
||||
"code": await secureStorageService.read("temp_token"),
|
||||
"is_2FA_on": false,
|
||||
"deviceId": await DeviceInfoData().getDeviceId(),
|
||||
"biometric_type":
|
||||
Platform.isIOS ? "face" : "fingerprint"
|
||||
};
|
||||
|
||||
goRouter.goNamed(RouteName.pinScreen, pathParameters: {
|
||||
"fromScreen": "register",
|
||||
});
|
||||
ResponseData response = await RegisterAPIService()
|
||||
.BiometricUpdate(biometricdata);
|
||||
if (response.status == ResponseStatus.SUCCESS) {
|
||||
goRouter.pop();
|
||||
|
||||
await secureStorageService.write("biometric", 'of');
|
||||
|
||||
goRouter.pop();
|
||||
|
||||
goRouter
|
||||
.goNamed(RouteName.pinScreen, pathParameters: {
|
||||
"fromScreen": "register",
|
||||
});
|
||||
}
|
||||
},
|
||||
child: SizedBox(
|
||||
height: 48.h,
|
||||
@@ -112,9 +133,11 @@ permissionDialog(
|
||||
onTap: () async {
|
||||
Loader.loader(context);
|
||||
Map<String, dynamic> biometricdata = {
|
||||
"token":
|
||||
await secureStorageService.read("temp_token"),
|
||||
"is_2FA_on": true
|
||||
"code": await secureStorageService.read("temp_token"),
|
||||
"is_2FA_on": true,
|
||||
"deviceId": await DeviceInfoData().getDeviceId(),
|
||||
"biometric_type":
|
||||
Platform.isIOS ? "face" : "fingerprint"
|
||||
};
|
||||
|
||||
ResponseData response = await RegisterAPIService()
|
||||
@@ -125,7 +148,7 @@ permissionDialog(
|
||||
await secureStorageService.write("biometric", 'on');
|
||||
successToastMessage(context,
|
||||
"Biometric/Face Id Enabled Sucessfully !");
|
||||
// successToastMessage(context, "successful !");
|
||||
|
||||
goRouter.pop();
|
||||
|
||||
goRouter
|
||||
|
||||
52
lib/shared/components/read_pdf.dart
Normal file
52
lib/shared/components/read_pdf.dart
Normal file
@@ -0,0 +1,52 @@
|
||||
import 'package:flutter/material.dart';
|
||||
import 'package:flutter_screenutil/flutter_screenutil.dart';
|
||||
import 'package:syncfusion_flutter_pdfviewer/pdfviewer.dart';
|
||||
|
||||
import '../../core/routes/routes.dart';
|
||||
import '../../core/styles/app_color.dart';
|
||||
import 'text_widget.dart';
|
||||
|
||||
class ReadPDF extends StatelessWidget {
|
||||
const ReadPDF({
|
||||
super.key,
|
||||
required this.title,
|
||||
required this.pdfUrl,
|
||||
});
|
||||
final String title;
|
||||
final String pdfUrl;
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
return Scaffold(
|
||||
backgroundColor: AppColor.plainWhite,
|
||||
appBar: AppBar(
|
||||
scrolledUnderElevation: 0.0,
|
||||
backgroundColor: AppColor.plainWhite,
|
||||
elevation: 0,
|
||||
centerTitle: true,
|
||||
title: TextWidget().text20W700(title, clr: AppColor.charcoalColor),
|
||||
leading: Padding(
|
||||
padding: EdgeInsets.only(
|
||||
left: 16.w,
|
||||
),
|
||||
child: GestureDetector(
|
||||
onTap: () {
|
||||
goRouter.pop();
|
||||
},
|
||||
child: Padding(
|
||||
padding: EdgeInsets.only(left: 8.w),
|
||||
child: Icon(
|
||||
Icons.arrow_back_rounded,
|
||||
color: AppColor.appBarIconColor,
|
||||
size: 25.r,
|
||||
),
|
||||
),
|
||||
),
|
||||
),
|
||||
),
|
||||
body: SfPdfViewer.network(
|
||||
pdfUrl,
|
||||
),
|
||||
);
|
||||
}
|
||||
}
|
||||
89
lib/shared/components/viemo_screen.dart
Normal file
89
lib/shared/components/viemo_screen.dart
Normal file
@@ -0,0 +1,89 @@
|
||||
import 'package:chewie/chewie.dart';
|
||||
import 'package:flutter/material.dart';
|
||||
import 'package:tanami_app/core/routes/routes.dart';
|
||||
import 'package:video_player/video_player.dart';
|
||||
|
||||
class VimeoScreen extends StatefulWidget {
|
||||
final String videoUrl;
|
||||
const VimeoScreen({
|
||||
super.key,
|
||||
required this.videoUrl,
|
||||
});
|
||||
|
||||
@override
|
||||
State<VimeoScreen> createState() => _VimeoScreenState();
|
||||
}
|
||||
|
||||
class _VimeoScreenState extends State<VimeoScreen> {
|
||||
late VideoPlayerController videoPlayerController;
|
||||
late ChewieController chewieController;
|
||||
var videoUrl1 =
|
||||
"https://player.vimeo.com/progressive_redirect/playback/848263896/rendition/1080p/file.mp4?loc=external&signature=440740807e0632840f08b973014d831dbb8d17516532a30d24bf10b44b9282cd";
|
||||
@override
|
||||
void initState() {
|
||||
_initializePlayer();
|
||||
super.initState();
|
||||
}
|
||||
|
||||
_initializePlayer() async {
|
||||
try {
|
||||
videoPlayerController = VideoPlayerController.networkUrl(
|
||||
Uri.parse(videoUrl1),
|
||||
);
|
||||
|
||||
await videoPlayerController.initialize();
|
||||
initChewie();
|
||||
setState(() {});
|
||||
} catch (e) {
|
||||
print("Error initializing video player: $e");
|
||||
}
|
||||
}
|
||||
|
||||
initChewie() {
|
||||
chewieController = ChewieController(
|
||||
videoPlayerController: videoPlayerController,
|
||||
autoPlay: true,
|
||||
looping: false);
|
||||
}
|
||||
|
||||
@override
|
||||
void dispose() {
|
||||
videoPlayerController.dispose();
|
||||
chewieController.dispose();
|
||||
super.dispose();
|
||||
}
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
return videoPlayerController.value.isInitialized
|
||||
? Scaffold(
|
||||
backgroundColor: Colors.transparent,
|
||||
appBar: AppBar(
|
||||
backgroundColor: Colors.transparent,
|
||||
leading: InkWell(
|
||||
onTap: () => goRouter.pop(),
|
||||
child: const Icon(
|
||||
Icons.arrow_back_ios,
|
||||
color: Colors.white,
|
||||
),
|
||||
),
|
||||
),
|
||||
// CommonAppbar(titleTxt: ""),
|
||||
body: Center(
|
||||
child: AspectRatio(
|
||||
aspectRatio: videoPlayerController.value.aspectRatio,
|
||||
child: Chewie(
|
||||
controller: chewieController,
|
||||
),
|
||||
),
|
||||
),
|
||||
)
|
||||
: const Center(
|
||||
child:
|
||||
//ShimmerCommon(),
|
||||
CircularProgressIndicator(
|
||||
color: Color(0xFF0093FF),
|
||||
),
|
||||
);
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user