From 52264d2bcf0262fdd1b472fbbd165ab63537e0f1 Mon Sep 17 00:00:00 2001 From: AshutoshPatole Date: Fri, 19 Nov 2021 20:37:14 +0530 Subject: [PATCH] Add delete button to edit page with other details --- .../edit_profile_page_view.dart | 71 ++++++++++++++++++- .../edit_profile_page_view_model.dart | 8 +++ 2 files changed, 76 insertions(+), 3 deletions(-) diff --git a/lib/views/edit_profile_page/edit_profile_page_view.dart b/lib/views/edit_profile_page/edit_profile_page_view.dart index 79483e4..bd8566e 100644 --- a/lib/views/edit_profile_page/edit_profile_page_view.dart +++ b/lib/views/edit_profile_page/edit_profile_page_view.dart @@ -1,3 +1,4 @@ +import 'package:flutter/cupertino.dart'; import 'package:flutter/material.dart'; import 'package:stacked/stacked.dart'; import 'package:zerosandones/theme/app_theme.dart'; @@ -59,9 +60,73 @@ class EditProfilePageView extends StatelessWidget { itemName: "Name", itemData: viewModel.user.displayName!), ProfileRow( itemName: "Email", itemData: viewModel.user.email!), - ProfileRow( - itemName: "Phone Number", - itemData: viewModel.user.phoneNumber ?? "N/A"), + Stack( + children: [ + ProfileRow( + itemName: "Phone Number", + itemData: viewModel.user.phoneNumber ?? "N/A"), + Positioned( + left: _size.width * 0.31, + bottom: 8, + child: GestureDetector( + onTap: () { + viewModel.navigateToPhoneAuthenticationPage(); + }, + child: const Icon( + CupertinoIcons.pencil_circle, + size: 20, + color: AppTheme.primaryColor, + ), + ), + ) + ], + ), + SizedBox( + height: _size.height * 0.1, + ), + Align( + alignment: Alignment.center, + child: TextButton( + child: const Text( + "Delete Account", + style: TextStyle( + color: Colors.red, + fontSize: 18.0, + fontWeight: FontWeight.w700, + ), + ), + onPressed: () { + // ON HOLD + // TODO: Implement delete account firebase extension + }, + ), + ), + SizedBox( + height: _size.height * 0.1, + ), + Align( + alignment: Alignment.center, + child: Text( + viewModel.user.uid, + style: const TextStyle( + fontSize: 12.0, + fontWeight: FontWeight.w500, + ), + ), + ), + SizedBox( + height: _size.height * 0.02, + ), + const Align( + alignment: Alignment.center, + child: Text( + "App Version 0.0.1", + style: TextStyle( + fontSize: 12.0, + fontWeight: FontWeight.w500, + ), + ), + ) ], ), ), diff --git a/lib/views/edit_profile_page/edit_profile_page_view_model.dart b/lib/views/edit_profile_page/edit_profile_page_view_model.dart index 32028f5..57a2b25 100644 --- a/lib/views/edit_profile_page/edit_profile_page_view_model.dart +++ b/lib/views/edit_profile_page/edit_profile_page_view_model.dart @@ -1,7 +1,10 @@ import 'package:firebase_auth/firebase_auth.dart'; import 'package:logger/logger.dart'; import 'package:stacked/stacked.dart'; +import 'package:stacked_services/stacked_services.dart'; +import 'package:zerosandones/core/locator.dart'; import 'package:zerosandones/core/logger.dart'; +import 'package:zerosandones/core/router_constants.dart'; class EditProfilePageViewModel extends BaseViewModel { late Logger log; @@ -10,4 +13,9 @@ class EditProfilePageViewModel extends BaseViewModel { log = getLogger(runtimeType.toString()); } User user = FirebaseAuth.instance.currentUser!; + final NavigationService _navigationService = locator(); + + navigateToPhoneAuthenticationPage() { + _navigationService.navigateTo(phoneAuthPageViewRoute); + } }