Fix code review comments

This commit is contained in:
shilangyu 2022-05-03 09:44:07 +02:00
parent d2c85cb305
commit 7bb8d2b33f
4 changed files with 65 additions and 56 deletions

View File

@ -5,7 +5,6 @@ import 'util/hot_rank.dart';
enum CommentSortType {
hot,
top,
// ignore: constant_identifier_names
new_,
old,
chat,

View File

@ -32,7 +32,8 @@ class CreatePostCommunityPicker extends HookWidget {
controller.text = '';
}
},
child: TypeAheadFormField<CommunityView>(
child: ObserverBuilder<CreatePostStore>(builder: (context, store) {
return TypeAheadFormField<CommunityView>(
textFieldConfiguration: TextFieldConfiguration(
controller: controller,
enabled: !store.isEdit,
@ -42,7 +43,15 @@ class CreatePostCommunityPicker extends HookWidget {
vertical: 16,
horizontal: 20,
),
suffixIcon: const Icon(Icons.arrow_drop_down),
suffixIcon: store.selectedCommunity == null
? const Icon(Icons.arrow_drop_down)
: IconButton(
onPressed: () {
store.selectedCommunity = null;
controller.clear();
},
icon: const Icon(Icons.close),
),
),
onChanged: (_) => store.selectedCommunity = null,
),
@ -88,7 +97,8 @@ class CreatePostCommunityPicker extends HookWidget {
],
),
debounceDuration: const Duration(milliseconds: 400),
),
);
}),
),
);
}

View File

@ -59,7 +59,7 @@ abstract class _CreatePostStore with Store {
ListCommunities(
type: PostListingType.all,
sort: SortType.topAll,
limit: 20,
limit: 10,
auth: token?.raw,
),
);
@ -70,7 +70,7 @@ abstract class _CreatePostStore with Store {
q: searchTerm,
sort: SortType.topAll,
listingType: PostListingType.all,
limit: 20,
limit: 10,
auth: token?.raw,
),
);

View File

@ -34,7 +34,7 @@ class CreatePostUrlField extends HookWidget {
return ObserverConsumer<CreatePostStore>(
listener: (context, store) {
// needed since flutter's TextFields cannot work as dumb widgets
// needed to keep the controller and store data in sync
if (controller.text != store.url) {
controller.text = store.url;
}