Skip to content

Commit

Permalink
Fix some bugs and typos
Browse files Browse the repository at this point in the history
Development
  • Loading branch information
bagussubagja authored Dec 13, 2022
2 parents 07f02ad + 810a0a8 commit 64467d5
Show file tree
Hide file tree
Showing 17 changed files with 289 additions and 345 deletions.
6 changes: 3 additions & 3 deletions lib/core/authentication/user_notifier.dart
Original file line number Diff line number Diff line change
Expand Up @@ -70,11 +70,11 @@ class UserUpdateSelfDataClass extends ChangeNotifier {
Future<void> updateSelfData(
UserModel body, String idUser, BuildContext context) async {
notifyListeners();
http.Response response = (await updateSelfDataUser(body, idUser, context))!;
if (response.statusCode == 204) {
http.Response? response = (await updateSelfDataUser(body, idUser, context));
if (response?.statusCode == 204) {
debugPrint('Update Berhasil');
} else {
debugPrint(response.statusCode.toString());
debugPrint(response?.statusCode.toString());
}
notifyListeners();
}
Expand Down
6 changes: 3 additions & 3 deletions lib/routes/routes.dart
Original file line number Diff line number Diff line change
Expand Up @@ -15,8 +15,8 @@ import 'package:healthy_buddy_mobile_app/screens/home/top_article/top_article_sc
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-calculator-screen/food_calculator_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';
import 'package:healthy_buddy_mobile_app/screens/main_features_screens/foodies/food-recipe-screen/food_recipe_detail_screen.dart';
import 'package:healthy_buddy_mobile_app/screens/main_features_screens/foodies/food-recipe-screen/food_recipe_menu.dart';
import 'package:healthy_buddy_mobile_app/screens/main_features_screens/foodies/food-store-screen/food_store_detail_screen.dart';
import 'package:healthy_buddy_mobile_app/screens/main_features_screens/foodies/food-store-screen/food_store_main_screen.dart';
import 'package:healthy_buddy_mobile_app/screens/main_features_screens/foodies/food-store-screen/food_store_status_order_screen.dart';
Expand All @@ -34,7 +34,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-website-screen/sport_website_screen.dart';
import 'package:healthy_buddy_mobile_app/screens/main_features_screens/sport/sport_exercise_screen/sport_exercise_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/topup_screen.dart';
import 'package:healthy_buddy_mobile_app/screens/main_features_screens/topup_balance/topup_balance_screen.dart';
import 'package:healthy_buddy_mobile_app/screens/extras/no_internet_found_screen.dart';


Expand Down
80 changes: 50 additions & 30 deletions lib/screens/authentication/biodata_screen.dart
Original file line number Diff line number Diff line change
Expand Up @@ -72,7 +72,24 @@ class _BiodataScreenState extends State<BiodataScreen> {

String? _idUser;


Future<bool> _onWillPop() async {
return (await showDialog(
context: context,
builder: (context) => AlertDialog(
title: const Text('Peringatan!'),
content:
const Text('Kamu harus mengisi form biodata terlebih dahulu'),
actions: <Widget>[
TextButton(
onPressed: () =>
Navigator.of(context).pop(false), //<-- SEE HERE
child: const Text('Kembali'),
),
],
),
)) ??
false;
}

@override
void initState() {
Expand All @@ -86,35 +103,38 @@ class _BiodataScreenState extends State<BiodataScreen> {

@override
Widget build(BuildContext context) {
return GestureDetector(
onTap: () {
FocusScopeNode currentFocus = FocusScope.of(context);
if (!currentFocus.hasPrimaryFocus) {
currentFocus.unfocus();
}
},
child: Scaffold(
backgroundColor: bgColor,
appBar: AppBar(
backgroundColor: Colors.transparent,
elevation: 0,
),
body: SafeArea(
child: Padding(
padding: defaultPadding,
child: ListView(
shrinkWrap: true,
children: [
_headerSection(),
MarginHeight(height: 5.h),
_textFieldSection(),
MarginHeight(height: 3.h),
_dropDownSection(),
MarginHeight(height: 3.h),
_confirmationButton()
],
return WillPopScope(
onWillPop: _onWillPop,
child: GestureDetector(
onTap: () {
FocusScopeNode currentFocus = FocusScope.of(context);
if (!currentFocus.hasPrimaryFocus) {
currentFocus.unfocus();
}
},
child: Scaffold(
backgroundColor: bgColor,
appBar: AppBar(
backgroundColor: Colors.transparent,
elevation: 0,
),
)),
body: SafeArea(
child: Padding(
padding: defaultPadding,
child: ListView(
shrinkWrap: true,
children: [
_headerSection(),
MarginHeight(height: 5.h),
_textFieldSection(),
MarginHeight(height: 3.h),
_dropDownSection(),
MarginHeight(height: 3.h),
_confirmationButton()
],
),
)),
),
),
);
}
Expand Down Expand Up @@ -165,7 +185,7 @@ class _BiodataScreenState extends State<BiodataScreen> {
MarginHeight(height: 3.h),
CustomTextField(
titleText: "Berat Badan",
hintText: "ex. 50 (dalam satuan kg)58",
hintText: "ex. 50 (dalam satuan kg)",
color: Colors.white,
controller: _weightController,
textInputType: TextInputType.number,
Expand Down
2 changes: 1 addition & 1 deletion lib/screens/home/favorites/favorite_screen.dart
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ import 'package:cached_network_image/cached_network_image.dart';
import 'package:flutter/material.dart';
import 'package:flutter_svg/flutter_svg.dart';
import 'package:healthy_buddy_mobile_app/core/favorites/favorites_notifier.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-recipe-screen/food_recipe_detail_screen.dart';
import 'package:healthy_buddy_mobile_app/screens/main_features_screens/mydoc/detail_screen/mydoc_detail_screen.dart';
import 'package:healthy_buddy_mobile_app/screens/widgets/margin_height.dart';
import 'package:healthy_buddy_mobile_app/shared/theme.dart';
Expand Down
185 changes: 105 additions & 80 deletions lib/screens/home/home_page.dart
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
import 'package:cache_manager/cache_manager.dart';
import 'package:cached_network_image/cached_network_image.dart';
import 'package:flutter/material.dart';
import 'package:flutter/services.dart';
import 'package:healthy_buddy_mobile_app/core/authentication/user_notifier.dart';
import 'package:healthy_buddy_mobile_app/core/extras/top_article_notifier.dart';
import 'package:healthy_buddy_mobile_app/routes/routes.dart';
Expand All @@ -25,7 +26,6 @@ class HomePage extends StatefulWidget {
}

class _HomePageState extends State<HomePage> {

final List<String> _categoryIcon = [
'foodies.png',
'sport.png',
Expand All @@ -48,97 +48,122 @@ class _HomePageState extends State<HomePage> {
});
}

Future<bool> _onWillPop() async {
return (await showDialog(
context: context,
builder: (context) => AlertDialog(
title: const Text('Konfirmasi?'),
content: const Text(
'Apakah kamu yakin untuk keluar dari aplikasi Healthy Buddy Mobile App?'),
actions: <Widget>[
TextButton(
onPressed: () => SystemNavigator.pop(),
child: const Text('Ya'),
),
TextButton(
onPressed: () => Navigator.of(context).pop(true),
child: const Text('Tidak'),
),
],
),
)) ??
false;
}

@override
Widget build(BuildContext context) {
final AuthenticationNotifier authenticationNotifier =
Provider.of<AuthenticationNotifier>(context, listen: false);

return GestureDetector(
onTap: () {
FocusScopeNode currentFocus = FocusScope.of(context);
if (!currentFocus.hasPrimaryFocus) {
currentFocus.unfocus();
}
},
child: Scaffold(
backgroundColor: greenColor,
appBar: AppBar(
return WillPopScope(
onWillPop: _onWillPop,
child: GestureDetector(
onTap: () {
FocusScopeNode currentFocus = FocusScope.of(context);
if (!currentFocus.hasPrimaryFocus) {
currentFocus.unfocus();
}
},
child: Scaffold(
backgroundColor: greenColor,
elevation: 0,
actions: [
PopupMenuButton(
elevation: 0,
icon: const Icon(Icons.more_horiz_rounded),
shape: const RoundedRectangleBorder(
borderRadius: BorderRadius.all(Radius.circular(4))),
color: bgColor,
itemBuilder: (context) => [
PopupMenuItem(
child: GestureDetector(
onTap: () async {
DeleteCache.deleteKey(
"cache",
Navigator.pushNamedAndRemoveUntil(context,
AppRoutes.loginScreen, (route) => false));
appBar: AppBar(
backgroundColor: greenColor,
elevation: 0,
actions: [
PopupMenuButton(
elevation: 0,
icon: const Icon(Icons.more_horiz_rounded),
shape: const RoundedRectangleBorder(
borderRadius: BorderRadius.all(Radius.circular(4))),
color: bgColor,
itemBuilder: (context) => [
PopupMenuItem(
child: GestureDetector(
onTap: () async {
DeleteCache.deleteKey(
"cache",
Navigator.pushNamedAndRemoveUntil(context,
AppRoutes.loginScreen, (route) => false));

await authenticationNotifier.logOut();
},
child: Row(
children: [
Icon(
Icons.exit_to_app,
color: greyTextColor,
),
Text(
'Log Out',
style: regularStyle,
),
],
await authenticationNotifier.logOut();
},
child: Row(
children: [
Icon(
Icons.exit_to_app,
color: greyTextColor,
),
Text(
'Log Out',
style: regularStyle,
),
],
),
),
),
),
])
],
),
drawer: _drawer(),
body: SafeArea(
child: ListView(
shrinkWrap: true,
children: [
MarginHeight(height: 15),
Padding(
padding: defaultPadding,
child: _headerIdentity(),
),
Padding(
padding: defaultPadding,
child: CustomTextField(
color: bgColor,
onTap: () {
showSearch(
context: context, delegate: SearchTopArticleResult());
},
readOnly: true,
prefixIcon: const Icon(
Icons.search,
),
hintText: "Cari artikel terhangat disini...",
])
],
),
drawer: _drawer(),
body: SafeArea(
child: ListView(
shrinkWrap: true,
children: [
MarginHeight(height: 15),
Padding(
padding: defaultPadding,
child: _headerIdentity(),
),
),
MarginHeight(height: 3.h),
Container(
width: double.infinity,
decoration: BoxDecoration(
borderRadius: const BorderRadius.vertical(
top: Radius.circular(30),
),
color: bgColor),
child: Padding(
Padding(
padding: defaultPadding,
child: _whiteSection(context),
child: CustomTextField(
color: bgColor,
onTap: () {
showSearch(
context: context, delegate: SearchTopArticleResult());
},
readOnly: true,
prefixIcon: const Icon(
Icons.search,
),
hintText: "Cari artikel terhangat disini...",
),
),
)
],
MarginHeight(height: 3.h),
Container(
width: double.infinity,
decoration: BoxDecoration(
borderRadius: const BorderRadius.vertical(
top: Radius.circular(30),
),
color: bgColor),
child: Padding(
padding: defaultPadding,
child: _whiteSection(context),
),
)
],
),
),
),
),
Expand Down
5 changes: 2 additions & 3 deletions lib/screens/home/profile_screen.dart
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,7 @@ class _ProfileScreenState extends State<ProfileScreen> {
child: ListView(
children: [
MarginHeight(height: 2.h),
_headerSection(),
_headerSection(user),
MarginHeight(height: 2.h),
_mainSection()
],
Expand All @@ -63,8 +63,7 @@ class _ProfileScreenState extends State<ProfileScreen> {
);
}

Widget _headerSection() {
final user = Provider.of<UserClass>(context);
Widget _headerSection(UserClass user) {
return Column(
children: [
ClipRRect(
Expand Down
Loading

0 comments on commit 64467d5

Please sign in to comment.