|
|
|
|
@ -24,7 +24,7 @@ class UserInfoFlowManager extends StatefulWidget {
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
class _UserInfoFlowManagerState extends State<UserInfoFlowManager> {
|
|
|
|
|
final PageController _pageController = PageController();
|
|
|
|
|
late PageController _pageController;
|
|
|
|
|
late SymptomsCheckerViewModel _viewModel;
|
|
|
|
|
|
|
|
|
|
// Page titles
|
|
|
|
|
@ -39,6 +39,8 @@ class _UserInfoFlowManagerState extends State<UserInfoFlowManager> {
|
|
|
|
|
void initState() {
|
|
|
|
|
super.initState();
|
|
|
|
|
_viewModel = context.read<SymptomsCheckerViewModel>();
|
|
|
|
|
// Initialize PageController with the current page from ViewModel
|
|
|
|
|
_pageController = PageController(initialPage: _viewModel.userInfoCurrentPage);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
@override
|
|
|
|
|
@ -48,6 +50,13 @@ class _UserInfoFlowManagerState extends State<UserInfoFlowManager> {
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void _onNext() {
|
|
|
|
|
// If in single page edit mode, just save and go back
|
|
|
|
|
if (_viewModel.isSinglePageEditMode) {
|
|
|
|
|
context.pop();
|
|
|
|
|
return;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
// Otherwise, continue with normal flow
|
|
|
|
|
if (_viewModel.userInfoCurrentPage < 3) {
|
|
|
|
|
_viewModel.nextUserInfoPage();
|
|
|
|
|
_pageController.animateToPage(
|
|
|
|
|
@ -162,6 +171,8 @@ class _UserInfoFlowManagerState extends State<UserInfoFlowManager> {
|
|
|
|
|
return Consumer<SymptomsCheckerViewModel>(builder: (BuildContext context, viewModel, child) {
|
|
|
|
|
bool isLastPage = viewModel.isUserInfoLastPage;
|
|
|
|
|
bool isFirstPage = viewModel.isUserInfoFirstPage;
|
|
|
|
|
bool isSingleEdit = viewModel.isSinglePageEditMode;
|
|
|
|
|
|
|
|
|
|
return Container(
|
|
|
|
|
decoration: BoxDecoration(
|
|
|
|
|
color: AppColors.whiteColor,
|
|
|
|
|
@ -170,33 +181,44 @@ class _UserInfoFlowManagerState extends State<UserInfoFlowManager> {
|
|
|
|
|
padding: EdgeInsets.only(left: 24.w, right: 24.w, top: 16.h),
|
|
|
|
|
child: SafeArea(
|
|
|
|
|
top: false,
|
|
|
|
|
child: Row(
|
|
|
|
|
children: [
|
|
|
|
|
if (!isFirstPage) ...[
|
|
|
|
|
Expanded(
|
|
|
|
|
child: CustomButton(
|
|
|
|
|
text: "Previous".needTranslation,
|
|
|
|
|
onPressed: _onPrevious,
|
|
|
|
|
backgroundColor: AppColors.primaryRedColor.withValues(alpha: 0.11),
|
|
|
|
|
borderColor: Colors.transparent,
|
|
|
|
|
textColor: AppColors.primaryRedColor,
|
|
|
|
|
fontSize: 16.f,
|
|
|
|
|
),
|
|
|
|
|
),
|
|
|
|
|
SizedBox(width: 12.w),
|
|
|
|
|
],
|
|
|
|
|
Expanded(
|
|
|
|
|
child: CustomButton(
|
|
|
|
|
text: isLastPage ? "Submit".needTranslation : "Next".needTranslation,
|
|
|
|
|
child: isSingleEdit
|
|
|
|
|
? // Single page edit mode - show only Save button
|
|
|
|
|
CustomButton(
|
|
|
|
|
text: "Save".needTranslation,
|
|
|
|
|
onPressed: _onNext,
|
|
|
|
|
backgroundColor: AppColors.primaryRedColor,
|
|
|
|
|
borderColor: AppColors.primaryRedColor,
|
|
|
|
|
textColor: AppColors.whiteColor,
|
|
|
|
|
fontSize: 16.f,
|
|
|
|
|
)
|
|
|
|
|
: // Complete flow mode - show Previous/Next buttons
|
|
|
|
|
Row(
|
|
|
|
|
children: [
|
|
|
|
|
if (!isFirstPage) ...[
|
|
|
|
|
Expanded(
|
|
|
|
|
child: CustomButton(
|
|
|
|
|
text: "Previous".needTranslation,
|
|
|
|
|
onPressed: _onPrevious,
|
|
|
|
|
backgroundColor: AppColors.primaryRedColor.withValues(alpha: 0.11),
|
|
|
|
|
borderColor: Colors.transparent,
|
|
|
|
|
textColor: AppColors.primaryRedColor,
|
|
|
|
|
fontSize: 16.f,
|
|
|
|
|
),
|
|
|
|
|
),
|
|
|
|
|
SizedBox(width: 12.w),
|
|
|
|
|
],
|
|
|
|
|
Expanded(
|
|
|
|
|
child: CustomButton(
|
|
|
|
|
text: isLastPage ? "Submit".needTranslation : "Next".needTranslation,
|
|
|
|
|
onPressed: _onNext,
|
|
|
|
|
backgroundColor: AppColors.primaryRedColor,
|
|
|
|
|
borderColor: AppColors.primaryRedColor,
|
|
|
|
|
textColor: AppColors.whiteColor,
|
|
|
|
|
fontSize: 16.f,
|
|
|
|
|
),
|
|
|
|
|
),
|
|
|
|
|
],
|
|
|
|
|
),
|
|
|
|
|
),
|
|
|
|
|
],
|
|
|
|
|
),
|
|
|
|
|
),
|
|
|
|
|
);
|
|
|
|
|
});
|
|
|
|
|
@ -217,8 +239,9 @@ class _UserInfoFlowManagerState extends State<UserInfoFlowManager> {
|
|
|
|
|
crossAxisAlignment: CrossAxisAlignment.start,
|
|
|
|
|
children: [
|
|
|
|
|
SizedBox(height: 24.h),
|
|
|
|
|
_buildProgressBar(),
|
|
|
|
|
SizedBox(height: 24.h),
|
|
|
|
|
// Only show progress bar in complete flow mode
|
|
|
|
|
if (!_viewModel.isSinglePageEditMode) _buildProgressBar(),
|
|
|
|
|
if (!_viewModel.isSinglePageEditMode) SizedBox(height: 24.h),
|
|
|
|
|
SizedBox(
|
|
|
|
|
height: 600.h,
|
|
|
|
|
child: PageView(
|
|
|
|
|
|