Skip to content

Commit

Permalink
app with api v6
Browse files Browse the repository at this point in the history
  • Loading branch information
mayed123502 committed Aug 28, 2022
1 parent cc8fab9 commit 7ebdc87
Show file tree
Hide file tree
Showing 13 changed files with 163 additions and 79 deletions.
Binary file added assets/hamburger.jpeg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
35 changes: 33 additions & 2 deletions lib/logic/controllers/food_controller.dart
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
import 'dart:ffi';

import 'package:flutter/material.dart';
import 'package:get/get.dart';

Expand All @@ -20,15 +22,23 @@ class FodeController extends GetxController {
late StatusRequest statusRequestFood;
var currentSeletected = 0.obs;
var currentSeletectedRating = 0.obs;
var currentSeletectedSlider = 0.obs;
var currentSeletectedSlider = 0.0.obs;
Rx<RangeValues> values = RangeValues(0, 100.00).obs;
RxString startLabel = 0.toString().obs;
RxString endLabel = 100.00.toString().obs;

final List sizeList = [
1,
2,
3,
4,
5,
].obs;

@override
void onInit() async {
await viewAllFood();
await viewCategories();
print(allFoodsList[1].name);
scrollController.addListener(_scrollListener);
}

Expand Down Expand Up @@ -76,4 +86,25 @@ class FodeController extends GetxController {

update();
}

filterProdect(
{required String category,
required int price,
required int rating,
required String subcategory}) async {
var response = await FoodApi.filterProdect(
category: category,
price: price,
rating: rating,
subcategory: subcategory);

if (response['status'] == 200) {
final dataList =
(response['data'] as List).map((e) => Data.fromJson(e)).toList();
print(dataList);
allCategoriesList.assignAll(dataList);
}

update();
}
}
17 changes: 17 additions & 0 deletions lib/services/food_services.dart
Original file line number Diff line number Diff line change
Expand Up @@ -28,4 +28,21 @@ class FoodApi {
);
return response.fold((l) => l, (r) => r);
}

static filterProdect({
required String category,
required String subcategory,
required int price,
required int rating,
}) async {
var url = '${BaseAPI.authPath}' + '/filter';
Map<String, dynamic> map = {
'category': category,
'subcategory': subcategory,
'price': price,
'rating': rating
};
var response = await Crud.getData(url, map: map);
return response.fold((l) => l, (r) => r);
}
}
2 changes: 1 addition & 1 deletion lib/view/screens/category_screen.dart
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ class CategoryScreen extends GetView<ResturantController> {
appBar: AppBarCategory(),
body: Obx(() {
final loadingType = controller.loadingState.value.loadingType;

print(controller.currentSeletected.value);
return Padding(
padding: EdgeInsets.symmetric(horizontal: 20.w, vertical: 20.h),
child: Column(
Expand Down
1 change: 1 addition & 0 deletions lib/view/screens/home_screen.dart
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,7 @@ class _HomeScreenState extends State<HomeScreen> {
child: SingleChildScrollView(
physics: AlwaysScrollableScrollPhysics(),
child: Column(
crossAxisAlignment: CrossAxisAlignment.start,
children: [
AppBarItem(),
SizedBox(
Expand Down
33 changes: 23 additions & 10 deletions lib/view/screens/notification_screen.dart
Original file line number Diff line number Diff line change
Expand Up @@ -8,28 +8,31 @@ class NotificatonScreen extends StatelessWidget {
const NotificatonScreen({Key? key}) : super(key: key);

@override
Widget build(BuildContext context) {
return Scaffold(
Widget build(BuildContext context) {
return Scaffold(
appBar: AppBar(
elevation: 0,
leading: IconButton(
leading: IconButton(
onPressed: () => Get.back(),
icon: Icon(
Icons.arrow_back_ios,
color: Theme.of(context).iconTheme.color,
),
),
title: Text('Notificaton',style: TextStyle(color: Theme.of(context).textTheme.headline1!.color),),
title: Text(
'Notificaton',
style: TextStyle(color: Theme.of(context).textTheme.headline1!.color),
),
),
body: Padding(
padding: EdgeInsets.symmetric(horizontal: 10.w),
child: ListView.builder(
itemCount: 5,

itemBuilder: (context, index) {
return Card(
// elevation: 0,
child: Padding(
padding: EdgeInsets.symmetric(vertical:15.h,horizontal: 5.w ),
padding: EdgeInsets.symmetric(vertical: 15.h, horizontal: 5.w),
child: Row(
children: [
ClipRRect(
Expand All @@ -45,15 +48,17 @@ class NotificatonScreen extends StatelessWidget {
mainAxisAlignment: MainAxisAlignment.start,
children: [
TextWithFont().textWithRalewayFont(
color: Theme.of(context).textTheme.headline1!.color!,
color:
Theme.of(context).textTheme.headline1!.color!,
fontSize: 16.sp,
text: 'Lorem Ipsum',
fontWeight: FontWeight.bold),
SizedBox(
height: 5.h,
),
TextWithFont().textWithRalewayFont(
color: Theme.of(context).textTheme.headline1!.color!,
color:
Theme.of(context).textTheme.headline1!.color!,
fontSize: 14.sp,
text: 'simply dummy text of the printing',
fontWeight: FontWeight.w500),
Expand All @@ -63,15 +68,23 @@ class NotificatonScreen extends StatelessWidget {
Row(
children: [
TextWithFont().textWithRalewayFont(
color: Theme.of(context).textTheme.headline1!.color!.withOpacity(.6),
color: Theme.of(context)
.textTheme
.headline1!
.color!
.withOpacity(.6),
fontSize: 14.sp,
text: 'Today',
fontWeight: FontWeight.w400),
SizedBox(
width: 100.h,
),
TextWithFont().textWithRalewayFont(
color: Theme.of(context).textTheme.headline1!.color!.withOpacity(.6),
color: Theme.of(context)
.textTheme
.headline1!
.color!
.withOpacity(.6),
fontSize: 14.sp,
text: '12:00Pm',
fontWeight: FontWeight.w400),
Expand Down
37 changes: 25 additions & 12 deletions lib/view/screens/search/searchForRestant.dart
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ import '../../../enums/loading_types.dart';
import '../../../logic/controllers/search_controller.dart';
import '../../../model/search/search_Model.dart';

import '../../../routes/routes.dart';
import '../../widgets/search/showNotFound.dart';
import '../../widgets/textWithFont.dart';

Expand Down Expand Up @@ -60,18 +61,30 @@ class SearchForRestrant extends StatelessWidget {
.toString(),
);
} else {
return ListTileCard(
subtitleWidget: TextWithFont().textWithRalewayFont(
color: Colors.black.withOpacity(.5),
fontSize: 16.sp,
text:
'${searchController.searchRestaurantList[index].address}',
fontWeight: FontWeight.w500),
dataProducts: DataProducts(),
dataRestaurant:
searchController.searchRestaurantList[index],
isProduct: false,
);
return GestureDetector(
onTap: () {
Get.toNamed(Routes.resturantScreen,
arguments: [
{
"id": searchController
.searchRestaurantList[index].id
.toString(),
}
]);
},
child: ListTileCard(
subtitleWidget: TextWithFont()
.textWithRalewayFont(
color: Colors.black.withOpacity(.5),
fontSize: 16.sp,
text:
'${searchController.searchRestaurantList[index].address}',
fontWeight: FontWeight.w500),
dataProducts: DataProducts(),
dataRestaurant: searchController
.searchRestaurantList[index],
isProduct: false,
));
}
}))
: ShowNotFound(),
Expand Down
2 changes: 1 addition & 1 deletion lib/view/screens/settings/tabBarScreen.dart
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ class TapBarScreen extends StatelessWidget {
ClipRRect(
child: SizedBox.fromSize(
size: Size.fromRadius(30), // Image radius
child: Image.asset('assets/hamburger.jpg',
child: Image.asset('assets/hamburger.jpeg',
fit: BoxFit.cover),
),
borderRadius: BorderRadius.circular(50),
Expand Down
15 changes: 13 additions & 2 deletions lib/view/widgets/AllFood/appBarMeal.dart
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,8 @@ import '../category/choseMenuRating.dart';
import '../search/filter/rangeSlider.dart';
import '../textWithFont.dart';

final controller = Get.find<FodeController>();

class AppBarMeal extends StatelessWidget with PreferredSizeWidget {
AppBarMeal({
Key? key,
Expand Down Expand Up @@ -72,7 +74,17 @@ void appModalBottomSheet(BuildContext context) {
Align(
alignment: Alignment.topRight,
child: TextButton(
onPressed: () {},
onPressed: () {
controller.filterProdect(
category: controller
.allCategoriesList[controller.currentSeletected.value]
.title!,
price: controller.currentSeletectedSlider.value.toInt(),
rating: controller
.sizeList[controller.currentSeletectedRating.value],
subcategory: 'subcategory1',
);
},
child: Text(
'Apply',
style: TextStyle(color: mainColor),
Expand Down Expand Up @@ -107,7 +119,6 @@ void appModalBottomSheet(BuildContext context) {
height: 20.h,
),
RangeSliderFiltter(),

SizedBox(
height: 70.h,
),
Expand Down
75 changes: 37 additions & 38 deletions lib/view/widgets/category/choseMenu.dart
Original file line number Diff line number Diff line change
Expand Up @@ -10,47 +10,46 @@ class ChoseMenu extends GetView<ResturantController> {
@override
Widget build(BuildContext context) {
return Container(
height: 60,
padding: const EdgeInsets.symmetric(vertical: 10),
child: ListView.separated(
scrollDirection: Axis.horizontal,
itemBuilder: (context, index) {
return GestureDetector(
onTap: () {
controller.currentSeletected.value = index;
},
child: Obx(
() => Container(
padding:
const EdgeInsets.symmetric(horizontal: 15, vertical: 10),
decoration: BoxDecoration(
color: controller.currentSeletected.value == index
? mainColor
: Colors.white,
borderRadius: BorderRadius.circular(15),
border: Border.all(
color: mainColor.withOpacity(0.4),
width: 2,
),
),
child: Text(
controller.allCategoriesList[index]! as String,
style: TextStyle(
height: 60,
padding: const EdgeInsets.symmetric(vertical: 10),
child: Obx(
() => ListView.separated(
scrollDirection: Axis.horizontal,
itemBuilder: (context, index) {
return GestureDetector(
onTap: () {
controller.currentSeletected.value = index;
},
child: Container(
padding:
const EdgeInsets.symmetric(horizontal: 15, vertical: 10),
decoration: BoxDecoration(
color: controller.currentSeletected.value == index
? Colors.white
: Colors.black.withOpacity(.3),
fontWeight: FontWeight.bold,
? mainColor
: Colors.white,
borderRadius: BorderRadius.circular(15),
border: Border.all(
color: mainColor.withOpacity(0.4),
width: 2,
),
),
child: Text(
controller.allCategoriesList[index]! as String,
style: TextStyle(
color: controller.currentSeletected.value == index
? Colors.white
: Colors.black.withOpacity(.3),
fontWeight: FontWeight.bold,
),
),
),
),
);
},
separatorBuilder: (context, index) => const SizedBox(
width: 10,
),
);
},
separatorBuilder: (context, index) => const SizedBox(
width: 10,
),
itemCount: controller.allCategoriesList.length,
),
);
itemCount: controller.allCategoriesList.length,
),
));
}
}
12 changes: 2 additions & 10 deletions lib/view/widgets/category/choseMenuRating.dart
Original file line number Diff line number Diff line change
Expand Up @@ -6,14 +6,6 @@ import '../../../logic/controllers/food_controller.dart';
import '../../../utils/theme.dart';

class ChoseMenuRating extends StatelessWidget {
final List<String> sizeList = [
'1',
'2',
'3',
'4',
'5',
];

final fodeController = Get.find<FodeController>();

@override
Expand Down Expand Up @@ -46,7 +38,7 @@ class ChoseMenuRating extends StatelessWidget {
mainAxisAlignment: MainAxisAlignment.start,
children: [
Text(
sizeList[index],
fodeController.sizeList[index].toString(),
style: TextStyle(
color:
fodeController.currentSeletectedRating.value ==
Expand Down Expand Up @@ -76,7 +68,7 @@ class ChoseMenuRating extends StatelessWidget {
separatorBuilder: (context, index) => const SizedBox(
width: 10,
),
itemCount: sizeList.length,
itemCount: fodeController.sizeList.length,
),
);
}
Expand Down
Loading

0 comments on commit 7ebdc87

Please sign in to comment.