Skip to content

Commit

Permalink
Add profile screen feature
Browse files Browse the repository at this point in the history
  • Loading branch information
bagussubagja committed Dec 2, 2022
1 parent 303a662 commit 0c35a3f
Show file tree
Hide file tree
Showing 17 changed files with 589 additions and 147 deletions.
4 changes: 2 additions & 2 deletions lib/core/authentication/auth_notifier.dart
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ class AuthenticationNotifier extends ChangeNotifier {
required BuildContext context}) async {
try {
dynamic userId = await _authenticationService.registerUser(
email: email, password: password);
email: email, password: password, context: context);
WriteCache.setString(key: 'cache', value: userId!).whenComplete(() {
Navigator.pushNamedAndRemoveUntil(
context, AppRoutes.biodataScreen, (route) => false,
Expand All @@ -44,7 +44,7 @@ class AuthenticationNotifier extends ChangeNotifier {
required BuildContext context}) async {
try {
dynamic userId = await _authenticationService.loginUser(
email: email, password: password);
email: email, password: password, context: context);
print('userId : $userId');
WriteCache.setString(key: 'cache', value: userId!).whenComplete(() {
Navigator.pushNamedAndRemoveUntil(
Expand Down
101 changes: 99 additions & 2 deletions lib/models/user_model/user_model.dart
Original file line number Diff line number Diff line change
@@ -1,9 +1,75 @@
// // To parse this JSON data, do
// //
// // final userModel = userModelFromJson(jsonString);

// import 'dart:convert';
// import 'dart:ffi';

// List<UserModel> userModelFromJson(String str) =>
// List<UserModel>.from(json.decode(str).map((x) => UserModel.fromJson(x)));

// String userModelToJson(List<UserModel> data) =>
// json.encode(List<dynamic>.from(data.map((x) => x.toJson())));

// class UserModel {
// UserModel({
// this.idUser,
// this.email,
// this.name,
// this.gender,
// this.hasDiscount,
// this.balance,
// this.address,
// });

// String? idUser;
// String? email;
// String? name;
// String? gender;
// bool? hasDiscount;
// int? balance;
// String? address;

// factory UserModel.fromJson(Map<String, dynamic> json) => UserModel(
// idUser: json["id_user"],
// email: json["email"],
// name: json["name"],
// gender: json["gender"],
// hasDiscount: json["hasDiscount"],
// balance: json["balance"] as int,
// address: json["address"],
// );

// Map<String, dynamic> toJson() => {
// "id_user": idUser,
// "email": email,
// "name": name,
// "gender": gender,
// "address": address,
// };

// Map<String, dynamic> updateName() => {
// "name": name,
// };

// Map<String, dynamic> updateAddress() => {
// "address": address,
// };

// Map<String, dynamic> updateBalanceData() => {
// "balance": balance,
// };

// Map<String, dynamic> updateDiscountStatus() => {
// "hasDiscount": hasDiscount,
// };
// }

// To parse this JSON data, do
//
// final userModel = userModelFromJson(jsonString);

import 'dart:convert';
import 'dart:ffi';

List<UserModel> userModelFromJson(String str) =>
List<UserModel>.from(json.decode(str).map((x) => UserModel.fromJson(x)));
Expand All @@ -13,31 +79,49 @@ String userModelToJson(List<UserModel> data) =>

class UserModel {
UserModel({
this.id,
this.idUser,
this.email,
this.name,
this.gender,
this.hasDiscount,
this.balance,
this.address,
this.age,
this.weight,
this.height,
this.dailyActivity,
this.dailyCalories,
});

int? id;
String? idUser;
String? email;
String? name;
String? gender;
bool? hasDiscount;
int? balance;
String? address;
int? age;
int? weight;
int? height;
String? dailyActivity;
double? dailyCalories;

factory UserModel.fromJson(Map<String, dynamic> json) => UserModel(
id: json["id"],
idUser: json["id_user"],
email: json["email"],
name: json["name"],
gender: json["gender"],
hasDiscount: json["hasDiscount"],
balance: json["balance"] as int,
balance: json["balance"],
address: json["address"],
age: json["age"],
weight: json["weight"],
height: json["height"],
dailyActivity: json["daily_activity"],
dailyCalories: json["daily_calories"].toDouble(),
);

Map<String, dynamic> toJson() => {
Expand All @@ -46,6 +130,11 @@ class UserModel {
"name": name,
"gender": gender,
"address": address,
"age": age,
"weight": weight,
"height": height,
"daily_activity": dailyActivity,
"daily_calories": dailyCalories,
};

Map<String, dynamic> updateName() => {
Expand All @@ -63,4 +152,12 @@ class UserModel {
Map<String, dynamic> updateDiscountStatus() => {
"hasDiscount": hasDiscount,
};

Map<String, dynamic> selfData() => {
"age": age,
"weight": weight,
"height": height,
"dailyActivity": dailyActivity,
"dailyCalories": dailyCalories
};
}
8 changes: 6 additions & 2 deletions lib/routes/routes.dart
Original file line number Diff line number Diff line change
Expand Up @@ -5,13 +5,14 @@ import 'package:healthy_buddy_mobile_app/models/mydoc_model/mydoc_model.dart';
import 'package:healthy_buddy_mobile_app/screens/authentication/biodata_screen.dart';
import 'package:healthy_buddy_mobile_app/screens/authentication/login_screen.dart';
import 'package:healthy_buddy_mobile_app/screens/authentication/register_screen.dart';
import 'package:healthy_buddy_mobile_app/screens/home/profile_screen.dart';
import 'package:healthy_buddy_mobile_app/screens/home/settings/about_us/about_us_screen.dart';
import 'package:healthy_buddy_mobile_app/screens/home/settings/account/account_settings_screen.dart';
import 'package:healthy_buddy_mobile_app/screens/home/settings/help_center/help_center_screen.dart';
import 'package:healthy_buddy_mobile_app/screens/home/settings/purchase_history/purcase_history_screen.dart';
import 'package:healthy_buddy_mobile_app/screens/home/state_ui.dart';
import 'package:healthy_buddy_mobile_app/screens/home/top_article/top_article_screen.dart';
import 'package:healthy_buddy_mobile_app/screens/home/whislist/wishslist_screen.dart';
import 'package:healthy_buddy_mobile_app/screens/home/wishslist/wishslist_screen.dart';
import 'package:healthy_buddy_mobile_app/screens/main_features_screens/foodies/food-article-screen/food_article_screen.dart';
import 'package:healthy_buddy_mobile_app/screens/main_features_screens/foodies/food-receipt-screen/food_receipt_detail_screen.dart';
import 'package:healthy_buddy_mobile_app/screens/main_features_screens/foodies/food-receipt-screen/food_receipt_menu.dart';
Expand All @@ -31,7 +32,7 @@ import 'package:healthy_buddy_mobile_app/screens/main_features_screens/sport/spo
import 'package:healthy_buddy_mobile_app/screens/main_features_screens/sport/sport-store-screen/sport_store_main_screen.dart';
import 'package:healthy_buddy_mobile_app/screens/main_features_screens/sport/sport-website-screen/sport_website_screen.dart';
import 'package:healthy_buddy_mobile_app/screens/main_features_screens/sport/sport_main_screen.dart';
import 'package:healthy_buddy_mobile_app/screens/main_features_screens/topup_screen/topup_screen.dart';
import 'package:healthy_buddy_mobile_app/screens/main_features_screens/topup/topup_screen.dart';
import 'package:healthy_buddy_mobile_app/screens/extras/no_internet_found_screen.dart';
import 'package:http/http.dart';

Expand All @@ -41,6 +42,7 @@ class AppRoutes {
static const String registerScreen = '/register';
static const String biodataScreen = '/biodata';
static const String homePageScreen = '/home';
static const String profileScreen = '/profile';
static const String wishlistScreen = '/wishlist';
static const String topArticleScreen = '/topArticleScreen';
static const String foodiesScreen = '/foodies';
Expand Down Expand Up @@ -108,6 +110,8 @@ class AppRoutes {
));
case AppRoutes.homePageScreen:
return getPage(HomePage());
case AppRoutes.profileScreen:
return getPage(ProfileScreen());
case AppRoutes.topArticleScreen:
return getPage(TopArticleScreen());
case AppRoutes.wishlistScreen:
Expand Down
Loading

0 comments on commit 0c35a3f

Please sign in to comment.