Skip to content

Commit

Permalink
Fix some bugs and new routing methode
Browse files Browse the repository at this point in the history
  • Loading branch information
bagussubagja committed Nov 15, 2022
1 parent eb176f2 commit 6daff89
Show file tree
Hide file tree
Showing 13 changed files with 1,052 additions and 181 deletions.
Binary file added assets/images/discount-offers2.jpg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,13 @@ import '../../services/carousel_services/get_carousel_article.dart';

class CarouselClass extends ChangeNotifier {
List<CarouselModel>? carousel;
getDataCarousel({required BuildContext context, required String section}) async {
bool isLoading = false;

getDataCarousel(
{required BuildContext context, required String section}) async {
isLoading = true;
carousel = (await getCarouselItem(context: context, section: section));
isLoading = false;
notifyListeners();
}
}
}
10 changes: 6 additions & 4 deletions lib/core/foodies/food_articles_notifier.dart
Original file line number Diff line number Diff line change
Expand Up @@ -6,12 +6,14 @@ import 'package:healthy_buddy_mobile_app/services/foodies_services/food_articles

class FoodArticlesClass extends ChangeNotifier {
List<FoodArticleModel>? foodArticle;
bool isLoading = false;

getFoodArticleData({required BuildContext context}) async {
isLoading = true;
print("test");
foodArticle = (await getFoodArticles(context: context));
print("ada");
isLoading = false;
notifyListeners();
}
}




41 changes: 41 additions & 0 deletions lib/core/sport/sport_store_notifier.dart
Original file line number Diff line number Diff line change
@@ -0,0 +1,41 @@
import 'package:flutter/material.dart';
import 'package:healthy_buddy_mobile_app/models/sport_model/sport_exercise_model.dart';
import 'package:healthy_buddy_mobile_app/models/sport_model/sport_store_model.dart';
import 'package:healthy_buddy_mobile_app/services/sport_services/sport_exercise_service.dart';
import 'package:healthy_buddy_mobile_app/services/sport_services/sport_store_service.dart';

class SportStoreGeneralClass extends ChangeNotifier {
List<SportStoreModel>? sportStore;
getSport({required BuildContext context, required String category}) async {
sportStore =
(await getSportStorebyCategory(context: context, category: 'General'));
notifyListeners();
}
}

class SportStoreSoccerClass extends ChangeNotifier {
List<SportStoreModel>? sportStore;
getSport({required BuildContext context, required String category}) async {
sportStore =
(await getSportStorebyCategory(context: context, category: 'Soccer'));
notifyListeners();
}
}

class SportStoreAthleticClass extends ChangeNotifier {
List<SportStoreModel>? sportStore;
getSport({required BuildContext context, required String category}) async {
sportStore =
(await getSportStorebyCategory(context: context, category: 'Athletic'));
notifyListeners();
}
}

class SportStoreBadmintonClass extends ChangeNotifier {
List<SportStoreModel>? sportStore;
getSport({required BuildContext context, required String category}) async {
sportStore =
(await getSportStorebyCategory(context: context, category: 'Badminton'));
notifyListeners();
}
}
1 change: 1 addition & 0 deletions lib/main.dart
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,7 @@ class HealthyBuddyApp extends StatelessWidget {
theme: ThemeData(primarySwatch: Colors.green, fontFamily: "Poppins"),
initialRoute: AppRoutes.bodyScreen,
routes: AppRoutes.routes,
onGenerateRoute:AppRoutes.handlingGenerateRoute,
);
},
);
Expand Down
57 changes: 57 additions & 0 deletions lib/models/sport_model/sport_store_model.dart
Original file line number Diff line number Diff line change
@@ -0,0 +1,57 @@
// To parse this JSON data, do
//
// final sportStoreModel = sportStoreModelFromJson(jsonString);

import 'dart:convert';

List<SportStoreModel> sportStoreModelFromJson(String str) => List<SportStoreModel>.from(json.decode(str).map((x) => SportStoreModel.fromJson(x)));

String sportStoreModelToJson(List<SportStoreModel> data) => json.encode(List<dynamic>.from(data.map((x) => x.toJson())));

class SportStoreModel {
SportStoreModel({
required this.id,
required this.productName,
required this.description,
required this.gallery,
required this.price,
required this.review,
required this.reviewerName,
required this.merk,
required this.category,
});

int id;
String productName;
String description;
List<String> gallery;
int price;
List<String> review;
List<String> reviewerName;
String merk;
String category;

factory SportStoreModel.fromJson(Map<String, dynamic> json) => SportStoreModel(
id: json["id"],
productName: json["product_name"],
description: json["description"],
gallery: List<String>.from(json["gallery"].map((x) => x)),
price: json["price"],
review: List<String>.from(json["review"].map((x) => x)),
reviewerName: List<String>.from(json["reviewer_name"].map((x) => x)),
merk: json["merk"],
category: json["category"],
);

Map<String, dynamic> toJson() => {
"id": id,
"product_name": productName,
"description": description,
"gallery": List<dynamic>.from(gallery.map((x) => x)),
"price": price,
"review": List<dynamic>.from(review.map((x) => x)),
"reviewer_name": List<dynamic>.from(reviewerName.map((x) => x)),
"merk": merk,
"category": category,
};
}
15 changes: 14 additions & 1 deletion lib/providers/providers_list.dart
Original file line number Diff line number Diff line change
Expand Up @@ -3,10 +3,11 @@ import 'package:healthy_buddy_mobile_app/core/foodies/food_articles_notifier.dar
import 'package:healthy_buddy_mobile_app/core/foodies/food_receipt_notifier.dart';
import 'package:healthy_buddy_mobile_app/core/foodies/food_store_notifier.dart';
import 'package:healthy_buddy_mobile_app/core/sport/sport_exercise_notifier.dart';
import 'package:healthy_buddy_mobile_app/core/sport/sport_store_notifier.dart';
import 'package:provider/provider.dart';
import 'package:provider/single_child_widget.dart';

import '../core/extras/extras_notifier.dart';
import '../core/extras/carousel_item_notifier.dart';

class ProviderList {
static List<SingleChildWidget> providers = [
Expand Down Expand Up @@ -55,5 +56,17 @@ class ProviderList {
ChangeNotifierProvider(
create: (_) => SportExerciseHardClass(),
),
ChangeNotifierProvider(
create: (_) => SportStoreGeneralClass(),
),
ChangeNotifierProvider(
create: (_) => SportStoreSoccerClass(),
),
ChangeNotifierProvider(
create: (_) => SportStoreAthleticClass(),
),
ChangeNotifierProvider(
create: (_) => SportStoreBadmintonClass(),
),
];
}
29 changes: 28 additions & 1 deletion lib/routes/routes.dart
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
import 'package:flutter/material.dart';
import 'package:healthy_buddy_mobile_app/models/foodies_model/food_store_model.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/state_ui.dart';
Expand All @@ -11,8 +13,10 @@ import 'package:healthy_buddy_mobile_app/screens/home/body_page_screen.dart';
import 'package:healthy_buddy_mobile_app/screens/home/home_page.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/main_features_screens/mydoc/mydoc_main_screen.dart';
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_main_screen.dart';
import 'package:healthy_buddy_mobile_app/screens/widgets/no_internet_found_screen.dart';
import 'package:http/http.dart';

class AppRoutes {
static const String notInternetScreen = '/nointernet';
Expand All @@ -26,6 +30,7 @@ class AppRoutes {
static const String foodStoreMenu = '/foodStore';
static const String foodStoreDetailScreen = '/foodStoreDetail';
static const String sportScreen = '/sport';
static const String sportStore = '/sportStore';
static const String myDocScreen = '/myDocScreen';
static const String myDocDetailScreen = '/myDocDetailScreen';
static const String bodyScreen = '/index';
Expand All @@ -38,14 +43,36 @@ class AppRoutes {
homePageScreen: (context) => HomePage(),
bodyScreen: (context) => BodyPageScreen(),
foodiesScreen: (context) => const FoodiesScreen(),
foodArticleMenu: (context) => FoodArticleScreen(),
foodArticleMenu: (context) => FoodArticleScreen(),
foodReceiptMenu: (context) => FoodReceiptMenuScreen(),
foodReceiptDetailScreen: (context) => FoodReceiptDetailScreen(),
foodStoreMenu: (context) => FoodStoreMainScreen(),
foodStoreDetailScreen: (context) => FoodStoreDetailScreen(),
sportScreen: (context) => const SportScreen(),
sportStore: (context) => SportStoreMainScreen(),
myDocScreen: (context) => MyDocMainScreen(),
myDocDetailScreen: (context) => MyDocDetailScreen(),
statePageUI: (context) => const StatePageUI(),
};

static Route<dynamic> handlingGenerateRoute(RouteSettings settings) {
String route = settings.name ?? '/';

switch (route) {
case AppRoutes.foodStoreDetailScreen:
final food = settings.arguments as FoodStoreModel;
return getPage(
FoodStoreDetailScreen(
foodStoreModel: food,
),
);

default:
return getPage(const Scaffold(
body: Text("Route Tidak Ada"),
));
}
}
}

MaterialPageRoute<dynamic> getPage(Widget page) => MaterialPageRoute(builder: (context) => page);
Original file line number Diff line number Diff line change
Expand Up @@ -476,13 +476,15 @@ class _FoodStoreMainScreenState extends State<FoodStoreMainScreen> {
onTap: () {
if (_currentIndex == 0) {
final itemBuah = itemByBuah.foodStoreModel?[index];
Navigator.push(context, MaterialPageRoute(
builder: (context) {
return FoodStoreDetailScreen(
foodStoreModel: itemBuah,
);
},
));
// Navigator.push(context, MaterialPageRoute(
// builder: (context) {
// return FoodStoreDetailScreen(
// foodStoreModel: itemBuah,
// );
// },
// ));
Navigator.pushNamed(context, AppRoutes.foodStoreDetailScreen,
arguments: itemBuah);
} else if (_currentIndex == 1) {
final itemSayuran = itemBySayuran.foodStoreModel?[index];
Navigator.push(context, MaterialPageRoute(
Expand Down
Loading

0 comments on commit 6daff89

Please sign in to comment.