didvan-app/lib/views/profile/change_password/change_password.dart

50 lines
1.4 KiB
Dart

import 'package:didvan/views/profile/change_password/widgets/verify_otp_screen.dart';
import 'package:didvan/views/profile/change_password/widgets/new_password_screen.dart';
import 'package:didvan/views/profile/change_password/change_password_state.dart';
import 'package:flutter/material.dart';
import 'package:provider/provider.dart';
class ChangePasswordPage extends StatefulWidget {
const ChangePasswordPage({Key? key}) : super(key: key);
@override
State<ChangePasswordPage> createState() => _ChangePasswordPageState();
}
class _ChangePasswordPageState extends State<ChangePasswordPage> {
late final List<Widget> _pages;
@override
void initState() {
super.initState();
_pages = const [
VerifyOtpScreen(),
NewPasswordScreen(),
];
WidgetsBinding.instance.addPostFrameCallback((_) {
context.read<ChangePasswordState>().sendOtp();
});
}
@override
Widget build(BuildContext context) {
return Scaffold(
body: Consumer<ChangePasswordState>(
builder: (context, state, child) => WillPopScope(
onWillPop: () async {
if (state.currentPageIndex == 0) {
return true;
}
state.currentPageIndex--;
return false;
},
child: AnimatedSwitcher(
duration: const Duration(milliseconds: 400),
child: _pages[state.currentPageIndex],
),
),
),
);
}
}