Skip to content

Commit a5842b7

Browse files
committed
Add search bar, update ui for dark mode
1 parent 2e98264 commit a5842b7

File tree

7 files changed

+213
-50
lines changed

7 files changed

+213
-50
lines changed

lib/app/features/about/view/about_view.dart

Lines changed: 21 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -34,14 +34,14 @@ https://gordonferguson.org/wp-content/uploads/2016/11/Final-Main-Header.jpg''';
3434
child: Scaffold(
3535
appBar: WpaAppBar(title: const Text('About'), actions: [SettingsIconButton()]),
3636
body: SingleChildScrollView(
37-
child: AdjustableTextWidget(
38-
child: Column(
39-
mainAxisAlignment: MainAxisAlignment.start,
40-
crossAxisAlignment: CrossAxisAlignment.center,
41-
children: [
42-
WpaImage(_imageUrl),
43-
SizedBox(height: 8.0),
44-
Padding(
37+
child: Column(
38+
mainAxisAlignment: MainAxisAlignment.start,
39+
crossAxisAlignment: CrossAxisAlignment.center,
40+
children: [
41+
WpaImage(_imageUrl),
42+
SizedBox(height: 8.0),
43+
AdjustableTextWidget(
44+
child: Padding(
4545
padding: const EdgeInsets.all(16.0),
4646
child: Container(
4747
padding: const EdgeInsets.all(16.0),
@@ -61,19 +61,19 @@ https://gordonferguson.org/wp-content/uploads/2016/11/Final-Main-Header.jpg''';
6161
),
6262
),
6363
),
64-
...urls.keys.map(
65-
(key) {
66-
final url = urls[key];
67-
return ElevatedButton(
68-
onPressed: () =>
69-
(url == _url.value) ? ref.invalidate(launchProvider) : _url.value = url,
70-
child: Text(key),
71-
);
72-
},
73-
),
74-
SizedBox(height: 16.0),
75-
],
76-
),
64+
),
65+
...urls.keys.map(
66+
(key) {
67+
final url = urls[key];
68+
return ElevatedButton(
69+
onPressed: () =>
70+
(url == _url.value) ? ref.invalidate(launchProvider) : _url.value = url,
71+
child: Text(key),
72+
);
73+
},
74+
),
75+
SizedBox(height: 16.0),
76+
],
7777
),
7878
),
7979
),

lib/app/features/posts/data/wordpress_client.dart

Lines changed: 14 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -21,11 +21,12 @@ abstract class WordpressClient {
2121
Future<HttpResponse<List<Post>>> getPosts(
2222
@Query('page') int page,
2323
@CancelRequest() CancelToken cancelToken, {
24+
@Query('categories') int? category,
2425
@Query('_embed') bool embed = true,
25-
@Query('per_page') int perPage = PAGE_SIZE,
2626
@Query('order') String? order,
2727
@Query('orderby') String? orderBy,
28-
@Query('categories') int? category,
28+
@Query('per_page') int perPage = PAGE_SIZE,
29+
@Query('search') String? search,
2930
});
3031

3132
@GET('/categories')
@@ -41,7 +42,14 @@ WordpressClient wordpressClient(Ref _) {
4142
//coverage:ignore-end
4243

4344
@riverpod
44-
FutureOr<PostResponse> getPosts(GetPostsRef ref, {required int page, int? category}) async {
45+
FutureOr<PostResponse> getPosts(
46+
GetPostsRef ref, {
47+
required int page,
48+
int? category,
49+
String? search,
50+
String? order,
51+
String? orderBy,
52+
}) async {
4553
final client = ref.watch(wordpressClientProvider);
4654

4755
final cancelToken = CancelToken();
@@ -67,6 +75,9 @@ FutureOr<PostResponse> getPosts(GetPostsRef ref, {required int page, int? catego
6775
page,
6876
cancelToken,
6977
category: category,
78+
search: search,
79+
order: order,
80+
orderBy: orderBy,
7081
),
7182
);
7283
}

lib/app/features/posts/data/wordpress_client.g.dart

Lines changed: 65 additions & 6 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

lib/app/features/posts/view/post_cell.dart

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@ import 'package:gordon_ferguson_app/app/features/posts/data/wordpress_client.dar
22
import 'package:gordon_ferguson_app/app/features/posts/domain/post.dart';
33
import 'package:gordon_ferguson_app/app/features/posts/view/favorite_icon_button.dart';
44
import 'package:gordon_ferguson_app/app/features/posts/view/share_icon_button.dart';
5+
import 'package:gordon_ferguson_app/app/features/theme_mode/theme_mode.dart';
56
import 'package:gordon_ferguson_app/app/shared/wpa_image.dart';
67
import 'package:flutter/material.dart';
78
import 'package:flutter_html/flutter_html.dart';
@@ -194,20 +195,21 @@ class PostCellFeatured extends StatelessWidget {
194195
);
195196
}
196197

197-
class PostCellLoading extends StatelessWidget {
198+
class PostCellLoading extends ConsumerWidget {
198199
const PostCellLoading({super.key, this.color});
199200

200201
final Color? color;
201202

202203
@override
203-
Widget build(BuildContext context) {
204+
Widget build(BuildContext context, WidgetRef ref) {
205+
final isLight = ref.watch(themeModeNotifierProvider) == ThemeMode.light;
204206
return Card(
205207
shadowColor: Colors.transparent,
206208
color: color,
207209
surfaceTintColor: (color == null) ? null : Colors.transparent,
208210
child: Shimmer.fromColors(
209-
baseColor: Colors.grey.shade200,
210-
highlightColor: Colors.grey.shade100,
211+
baseColor: isLight ? Colors.grey.shade200 : Colors.black38,
212+
highlightColor: isLight ? Colors.grey.shade100 : Colors.black12,
211213
enabled: true,
212214
child: Container(
213215
height: 150,

lib/app/features/posts/view/post_stream_table_view.dart

Lines changed: 32 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -11,14 +11,25 @@ import 'package:go_router/go_router.dart';
1111
import 'package:hooks_riverpod/hooks_riverpod.dart';
1212

1313
class PostStreamTableView extends ConsumerWidget {
14-
PostStreamTableView({super.key, this.category, this.tileColor});
14+
PostStreamTableView({super.key, this.category, this.search, this.tileColor});
1515

1616
final int? category;
17+
final String? search;
1718
final Color? tileColor;
1819

1920
@override
2021
Widget build(BuildContext context, WidgetRef ref) {
21-
final responseAsync = ref.watch(getPostsProvider(page: 1, category: category));
22+
final responseAsync = search != null
23+
? ref.watch(getPostsProvider(
24+
page: 1,
25+
category: category,
26+
search: search,
27+
orderBy: "relevance",
28+
))
29+
: ref.watch(getPostsProvider(
30+
page: 1,
31+
category: category,
32+
));
2233
final log = ref.watch(logManagerProvider);
2334
final pageSize = PAGE_SIZE;
2435

@@ -33,9 +44,17 @@ class PostStreamTableView extends ConsumerWidget {
3344
final page = index ~/ pageSize + 1;
3445
final indexInPage = index % pageSize;
3546

36-
final responseAsync = ref.watch(
37-
getPostsProvider(page: page, category: category),
38-
);
47+
final responseAsync = search != null
48+
? ref.watch(getPostsProvider(
49+
page: page,
50+
category: category,
51+
search: search,
52+
orderBy: "relevance",
53+
))
54+
: ref.watch(getPostsProvider(
55+
page: page,
56+
category: category,
57+
));
3958

4059
return responseAsync.when(
4160
error: (err, stack) => PostCellError(
@@ -56,15 +75,21 @@ class PostStreamTableView extends ConsumerWidget {
5675
post,
5776
key: Key('${PostsView.name}_${post.id}'),
5877
routeName: PostsView.name,
59-
onTap: () => context.pushNamed(PostDetailView.name, extra: post),
78+
onTap: () => context.pushNamed(
79+
PostDetailView.name,
80+
extra: post,
81+
),
6082
color: tileColor,
6183
);
6284
} else {
6385
return PostCell(
6486
post,
6587
key: Key('${PostsView.name}_${post.id}'),
6688
routeName: PostsView.name,
67-
onTap: () => context.pushNamed(PostDetailView.name, extra: post),
89+
onTap: () => context.pushNamed(
90+
PostDetailView.name,
91+
extra: post,
92+
),
6893
color: tileColor,
6994
);
7095
}

0 commit comments

Comments
 (0)