8000 Buat fitur pencarian meals · CoderJava/Food-Recipe@37582f7 · GitHub
[go: up one dir, main page]

Skip to content

Commit 37582f7

Browse files
committed
Buat fitur pencarian meals
1 parent 49df0d6 commit 37582f7

File tree

9 files changed

+377
-41
lines changed

9 files changed

+377
-41
lines changed

ios/Podfile.lock

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,20 +1,35 @@
11
PODS:
22
- Flutter (1.0.0)
3+
- FMDB (2.7.5):
4+
- FMDB/standard (= 2.7.5)
5+
- FMDB/standard (2.7.5)
6+
- sqflite (0.0.1):
7+
- Flutter
8+
- FMDB (~> 2.7.2)
39
- url_launcher (0.0.1):
410
- Flutter
511

612
DEPENDENCIES:
713
- Flutter (from `.symlinks/flutter/ios`)
14+
- sqflite (from `.symlinks/plugins/sqflite/ios`)
815
- url_launcher (from `.symlinks/plugins/url_launcher/ios`)
916

17+
SPEC REPOS:
18+
https://github.com/cocoapods/specs.git:
19+
- FMDB
20+
1021
EXTERNAL SOURCES:
1122
Flutter:
1223
:path: ".symlinks/flutter/ios"
24+
sqflite:
25+
:path: ".symlinks/plugins/sqflite/ios"
1326
url_launcher:
1427
:path: ".symlinks/plugins/url_launcher/ios"
1528

1629
SPEC CHECKSUMS:
1730
Flutter: 9d0fac939486c9aba2809b7982dfdbb47a7b0296
31+
FMDB: 2ce00b547f966261cd18927a3ddb07cb6f3db82a
32+
sqflite: d1612813fa7db7c667bed9f1d1b508deffc56999
1833
url_launcher: 92b89c1029a0373879933c21642958c874539095
1934

2035
PODFILE CHECKSUM: b7d0755641915265774624f3b3be49c5c073d379

ios/Runner.xcodeproj/project.pbxproj

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -222,14 +222,18 @@
222222
);
223223
inputPaths = (
224224
"${SRCROOT}/Pods/Target Support Files/Pods-Runner/Pods-Runner-frameworks.sh",
225+
"${BUILT_PRODUCTS_DIR}/FMDB/FMDB.framework",
225226
"${PODS_ROOT}/../.symlinks/flutter/ios/Flutter.framework",
227+
"${BUILT_PRODUCTS_DIR}/sqflite/sqflite.framework",
226228
"${BUILT_PRODUCTS_DIR}/url_launcher/url_launcher.framework",
227229
);
228230
name = "[CP] Embed Pods Frameworks";
229231
outputFileListPaths = (
230232
);
231233
outputPaths = (
234+
"${TARGET_BUILD_DIR}/${FRAMEWORKS_FOLDER_PATH}/FMDB.framework",
232235
"${TARGET_BUILD_DIR}/${FRAMEWORKS_FOLDER_PATH}/Flutter.framework",
236+
"${TARGET_BUILD_DIR}/${FRAMEWORKS_FOLDER_PATH}/sqflite.framework",
233237
"${TARGET_BUILD_DIR}/${FRAMEWORKS_FOLDER_PATH}/url_launcher.framework",
234238
);
235239
runOnlyForDeploymentPostprocessing = 0;

lib/src/app.dart

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,10 @@
11
import 'package:flutter/material.dart';
2-
import 'package:food_recipe/src/ui/listmeals/list_meals_screen.dart';
32
import 'package:food_recipe/values/color_assets.dart';
43

54
import 'ui/favorite/favorite_screen.dart';
65
import 'ui/home/home_screen.dart';
6+
import 'ui/listmeals/list_meals_screen.dart';
7+
import 'ui/searchmeals/search_meals_screen.dart';
78
import 'utils/utils.dart';
89

910
class App extends StatefulWidget {
@@ -22,6 +23,9 @@ class _AppState extends State<App> {
2223
navigatorListMeals: (context) {
2324
return ListMealsScreen();
2425
},
26+
navigatorSearchMeals: (context) {
27+
return SearchMealsScreen();
28+
}
2529
},
2630
theme: ThemeData(
2731
primaryColor: ColorAssets.primarySwatchColor,
Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,29 @@
1+
import 'package:food_recipe/src/models/searchmeals/search_meals.dart';
2+
import 'package:food_recipe/src/resources/repository.dart';
3+
import 'package:rxdart/rxdart.dart';
4+
5+
class SearchMealsBloc {
6+
final _repository = Repository();
7+
final _publishSubjectSearchMealsByKeyword = PublishSubject<SearchMeals>();
8+
9+
dispose() {
10+
_publishSubjectSearchMealsByKeyword.close();
11+
}
12+
13+
Observable<SearchMeals> get resultSearchMealsByKeyword =>
14+
_publishSubjectSearchMealsByKeyword.stream;
15+
16+
searchMealsByKeyword(String keyword) async {
17+
_publishSubjectSearchMealsByKeyword.sink.add(SearchMeals(isLoading: true));
18+
if (keyword.trim().isEmpty) {
19+
_publishSubjectSearchMealsByKeyword.sink
20+
.add(SearchMeals(searchMealsItems: []));
21+
} else {
22+
SearchMeals searchMeals =
23+
await _repository.getSearchMealsByKeyword(keyword);
24+
_publishSubjectSearchMealsByKeyword.sink.add(searchMeals);
25+
}
26+
}
27+
}
28+
29+
final searchMealsBloc = SearchMealsBloc();

lib/src/models/searchmeals/search_meals.dart

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,8 +5,10 @@ part 'search_meals.g.dart';
55
class SearchMeals {
66
@JsonKey(name: "meals")
77
List<SearchMealsItem> searchMealsItems;
8+
@JsonKey(ignore: true)
9+
bool isLoading;
810

9-
SearchMeals({this.searchMealsItems});
11+
SearchMeals({this.searchMealsItems, this.isLoading = false});
1012

1113
@override
1214
String toString() {

lib/src/ui/detailmeals/detail_meals_screen.dart

Lines changed: 24 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -157,26 +157,31 @@ class _DetailMealsScreenState extends State<DetailMealsScreen> {
157157
ingredients.add(ingredientItem);
158158
}
159159
return Padding(
160-
padding: EdgeInsets.only(left: 8.0, top: 8.0),
160+
padding: EdgeInsets.only(left: 8.0, top: 8.0, right: 8.0),
161161
child: ListView.builder(
162162
padding: EdgeInsets.all(0.0),
163163
shrinkWrap: true,
164164
physics: NeverScrollableScrollPhysics(),
165165
itemCount: ingredients.length,
166166
itemBuilder: (context, index) {
167167
return Row(
168-
crossAxisAlignment: CrossAxisAlignment.center,
168+
crossAxisAlignment: CrossAxisAlignment.start,
169169
children: <Widget>[
170-
Container(
171-
decoration: BoxDecoration(
172-
shape: BoxShape.circle,
173-
color: Colors.black54,
170+
Padding(
171+
padding: const EdgeInsets.only(top: 5.0),
172+
child: Container(
173+
decoration: BoxDecoration(
174+
shape: BoxShape.circle,
175+
color: Colors.black54,
176+
),
177+
width: 6.0,
178+
height: 6.0,
174179
),
175-
width: 6.0,
176-
height: 6.0,
177180
),
178181
Padding(padding: EdgeInsets.only(right: 16.0)),
179-
Text(ingredients[index]),
182+
Expanded(
183+
child: Text(ingredients[index]),
184+
),
180185
],
181186
);
182187
},
@@ -280,17 +285,23 @@ class _DetailMealsScreenState extends State<DetailMealsScreen> {
280285

281286
Widget _buildTagMeal(String strTags) {
282287
return Row(
288+
crossAxisAlignment: CrossAxisAlignment.start,
283289
children: <Widget>[
284290
Icon(
285291
Icons.label,
286292
color: Colors.black26,
287293
size: 24.0,
288294
),
289295
Padding(padding: EdgeInsets.only(left: 4.0)),
290-
Text(
291-
strTags.substring(0, strTags.length - 1),
292-
style: TextStyle(color: Colors.grey),
293-
maxLines: 1,
296+
Expanded(
297+
child: Padding(
298+
padding: const EdgeInsets.only(top: 3.5),
299+
child: Text(
300+
strTags != null ? strTags.substring(0, strTags.length - 1) : "N/A",
301+
style: TextStyle(color: Colors.grey),
302+
maxLines: 2,
303+
),
304+
),
294305
),
295306
],
296307
);

lib/src/ui/home/home_screen.dart

Lines changed: 32 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -260,36 +260,42 @@ class _HomeScreenState extends State<HomeScreen> {
260260
}
261261

262262
Widget _buildTextFieldSearchMeals() {
263-
return Container(
264-
decoration: BoxDecoration(
265-
borderRadius: BorderRadius.circular(36.0),
266-
color: Color(0x2FFFFFFF),
267-
),
268-
child: Padding(
269-
padding: const EdgeInsets.symmetric(
270-
horizontal: 12.0,
271-
vertical: 8.0,
263+
return GestureDetector(
264+
onTap: () {
265+
Navigator.pushNamed(context, navigatorSearchMeals);
266+
},
267+
child: Container(
268+
decoration: BoxDecoration(
269+
borderRadius: BorderRadius.circular(36.0),
270+
color: Color(0x2FFFFFFF),
272271
),
273-
child: Row(
274-
children: <Widget>[
275-
Icon(
276-
Icons.search,
277-
color: Colors.white,
278-
),
279-
Padding(padding: EdgeInsets.only(right: 8.0)),
280-
Expanded(
281-
child: TextField(
282-
decoration: InputDecoration.collapsed(
283-
hintText: "Search...",
284-
hintStyle: TextStyle(
285-
color: Colors.white70,
272+
child: Padding(
273+
padding: const EdgeInsets.symmetric(
274+
horizontal: 12.0,
275+
vertical: 8.0,
276+
),
277+
child: Row(
278+
children: <Widget>[
279+
Icon(
280+
Icons.search,
281+
color: Colors.white,
282+
),
283+
Padding(padding: EdgeInsets.only(right: 8.0)),
284+
Expanded(
285+
child: TextField(
286+
decoration: InputDecoration.collapsed(
287+
hintText: "Search...",
288+
hintStyle: TextStyle(
289+
color: Colors.white70,
290+
),
286291
),
292+
style: TextStyle(color: Colors.white),
293+
maxLines: 1,
294+
enabled: false,
287295
),
288-
style: TextStyle(color: Colors.white),
289-
maxLines: 1,
290296
),
291-
),
292-
],
297+
],
298+
),
293299
),
294300
),
295301
);

0 commit comments

Comments
 (0)
0