Skip to content
This repository has been archived by the owner on Jan 26, 2021. It is now read-only.

feat: add loading indicator when changing password and saving profile #83

Merged
10 changes: 10 additions & 0 deletions lib/screens/home/pages/profile/profile_page.dart
Original file line number Diff line number Diff line change
Expand Up @@ -56,6 +56,7 @@ class _ProfilePageState extends State<ProfilePage> {
final bloc = BlocProvider.of<ProfilePageBloc>(context);

if (state is ProfilePageEditing) {
showloader(context);
bloc.add(ProfilePageEditSubmitted(BlocProvider.of<ProfilePageBloc>(context).user));
} else if (state is ProfilePageSuccess) {
bloc.add(ProfilePageEditStarted());
Expand All @@ -70,6 +71,7 @@ class _ProfilePageState extends State<ProfilePage> {
listener: (context, state) {
if (state.message != null) {
context.showSnackBar(state.message);
Navigator.of(context).pop();
}
},
child: BlocBuilder<ProfilePageBloc, ProfilePageState>(builder: (context, state) {
Expand Down Expand Up @@ -220,4 +222,12 @@ class _ProfilePageState extends State<ProfilePage> {
),
);
}

Future<void> showloader(BuildContext context) {
techno-disaster marked this conversation as resolved.
Show resolved Hide resolved
return showDialog(
context: context,
barrierDismissible: false,
child: LoadingIndicator(),
);
}
}
33 changes: 21 additions & 12 deletions lib/screens/settings/settings_screen.dart
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ import 'package:mentorship_client/remote/repositories/user_repository.dart';
import 'package:mentorship_client/remote/requests/change_password.dart';
import 'package:mentorship_client/remote/responses/custom_response.dart';
import 'package:mentorship_client/screens/settings/about.dart';
import 'package:mentorship_client/widgets/loading_indicator.dart';

class SettingsScreen extends StatelessWidget {
@override
Expand Down Expand Up @@ -52,17 +53,18 @@ class SettingsScreen extends StatelessWidget {
);
}

void _showConfirmLogoutDialog(BuildContext context){
void _showConfirmLogoutDialog(BuildContext context) {
showDialog(
context: context,
builder:(context) {
builder: (context) {
return AlertDialog(
title : Text('Log Out'),
title: Text('Log Out'),
content: Text('Are you sure you want to logout?'),
actions: <Widget>[
FlatButton(
child: Text('Cancel'),
onPressed: ()=> Navigator.of(context).pop(),),
onPressed: () => Navigator.of(context).pop(),
),
FlatButton(
child: Text('Confirm'),
onPressed: () {
Expand All @@ -74,16 +76,15 @@ class SettingsScreen extends StatelessWidget {
),
],
);
}
},
);
}

Future<void> _showChangePasswordDialog(BuildContext context) async {
Future<void> _showChangePasswordDialog(BuildContext theContext) async {
techno-disaster marked this conversation as resolved.
Show resolved Hide resolved
final _currentPassController = TextEditingController();
final _newPassController = TextEditingController();

showDialog(
context: context,
context: theContext,
builder: (context) => AlertDialog(
title: Text("Change password"),
content: Column(
Expand All @@ -107,20 +108,28 @@ class SettingsScreen extends StatelessWidget {
currentPassword: _currentPassController.text,
newPassword: _newPassController.text,
);
Navigator.of(context).pop();
showloader(context);
try {
CustomResponse response =
await UserRepository.instance.changePassword(changePassword);
context.showSnackBar(response.message);
theContext.showSnackBar(response.message);
} on Failure catch (failure) {
context.showSnackBar(failure.message);
theContext.showSnackBar(failure.message);
}

Navigator.of(context).pop();
Navigator.of(theContext).pop();
},
),
],
),
);
}

Future<void> showloader(BuildContext context) {
return showDialog(
context: context,
barrierDismissible: false,
child: LoadingIndicator(),
);
}
}
59 changes: 40 additions & 19 deletions pubspec.lock
Original file line number Diff line number Diff line change
Expand Up @@ -7,14 +7,14 @@ packages:
name: _fe_analyzer_shared
url: "https://pub.dartlang.org"
source: hosted
version: "3.0.0"
version: "2.2.0"
analyzer:
dependency: transitive
description:
name: analyzer
url: "https://pub.dartlang.org"
source: hosted
version: "0.39.8"
version: "0.39.7"
archive:
dependency: transitive
description:
Expand Down Expand Up @@ -84,7 +84,7 @@ packages:
name: build_resolvers
url: "https://pub.dartlang.org"
source: hosted
version: "1.3.7"
version: "1.3.5"
build_runner:
dependency: "direct dev"
description:
Expand Down Expand Up @@ -112,7 +112,7 @@ packages:
name: built_value
url: "https://pub.dartlang.org"
source: hosted
version: "7.1.0"
version: "7.0.9"
charcode:
dependency: transitive
description:
Expand Down Expand Up @@ -141,6 +141,13 @@ packages:
url: "https://pub.dartlang.org"
source: hosted
version: "3.0.4"
clock:
dependency: transitive
description:
name: clock
url: "https://pub.dartlang.org"
source: hosted
version: "1.0.1"
code_builder:
dependency: transitive
description:
Expand Down Expand Up @@ -196,7 +203,7 @@ packages:
name: dart_style
url: "https://pub.dartlang.org"
source: hosted
version: "1.3.6"
version: "1.3.4"
equatable:
dependency: "direct main"
description:
Expand All @@ -210,7 +217,14 @@ packages:
name: expandable
url: "https://pub.dartlang.org"
source: hosted
version: "4.1.3"
version: "4.1.4"
fake_async:
dependency: transitive
description:
name: fake_async
url: "https://pub.dartlang.org"
source: hosted
version: "1.1.0"
fixnum:
dependency: transitive
description:
Expand Down Expand Up @@ -281,7 +295,7 @@ packages:
name: http
url: "https://pub.dartlang.org"
source: hosted
version: "0.12.1"
version: "0.12.0+4"
http_multi_server:
dependency: transitive
description:
Expand Down Expand Up @@ -379,7 +393,7 @@ packages:
name: node_io
url: "https://pub.dartlang.org"
source: hosted
version: "1.1.0"
version: "1.0.1+2"
package_config:
dependency: transitive
description:
Expand All @@ -400,7 +414,7 @@ packages:
name: path
url: "https://pub.dartlang.org"
source: hosted
version: "1.6.4"
version: "1.7.0"
pedantic:
dependency: transitive
description:
Expand All @@ -414,7 +428,14 @@ packages:
name: petitparser
url: "https://pub.dartlang.org"
source: hosted
version: "2.4.0"
version: "3.0.2"
platform_detect:
dependency: transitive
description:
name: platform_detect
url: "https://pub.dartlang.org"
source: hosted
version: "1.4.0"
plugin_platform_interface:
dependency: transitive
description:
Expand All @@ -435,7 +456,7 @@ packages:
name: provider
url: "https://pub.dartlang.org"
source: hosted
version: "4.1.0"
version: "4.0.5"
pub_semver:
dependency: transitive
description:
Expand Down Expand Up @@ -559,28 +580,28 @@ packages:
name: url_launcher
url: "https://pub.dartlang.org"
source: hosted
version: "5.4.5"
version: "5.4.10"
url_launcher_macos:
dependency: transitive
description:
name: url_launcher_macos
url: "https://pub.dartlang.org"
source: hosted
version: "0.0.1+5"
version: "0.0.1+7"
url_launcher_platform_interface:
dependency: transitive
description:
name: url_launcher_platform_interface
url: "https://pub.dartlang.org"
source: hosted
version: "1.0.6"
version: "1.0.7"
url_launcher_web:
dependency: transitive
description:
name: url_launcher_web
url: "https://pub.dartlang.org"
source: hosted
version: "0.1.1+4"
version: "0.1.1+6"
vector_math:
dependency: transitive
description:
Expand All @@ -594,7 +615,7 @@ packages:
name: watcher
url: "https://pub.dartlang.org"
source: hosted
version: "0.9.7+15"
version: "0.9.7+14"
web_socket_channel:
dependency: transitive
description:
Expand All @@ -608,14 +629,14 @@ packages:
name: xml
url: "https://pub.dartlang.org"
source: hosted
version: "3.6.1"
version: "3.7.0"
yaml:
dependency: transitive
description:
name: yaml
url: "https://pub.dartlang.org"
source: hosted
version: "2.2.1"
version: "2.2.0"
sdks:
dart: ">=2.7.0 <3.0.0"
flutter: ">=1.17.0 <2.0.0"
flutter: ">=1.12.13+hotfix.5 <2.0.0"