Skip to content

Commit f19b28f

Browse files
committed
adaptive ui
1 parent 776ce3b commit f19b28f

File tree

3 files changed

+59
-47
lines changed

3 files changed

+59
-47
lines changed

lib/pages/cached_articles.dart

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -47,7 +47,8 @@ class CachedArticlesList extends StatelessWidget {
4747
),
4848
);
4949
},
50-
separatorBuilder: (context, index) => const Hr(),
50+
separatorBuilder: (context, index) =>
51+
const DefaultConstraints(child: const Hr()),
5152
itemCount: () =>
5253
store.previews.length + (store.loadItems ? 1 : 0),
5354
loadMore: store.loadNextPage,

lib/pages/filters.dart

Lines changed: 12 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@ import 'package:habr_app/models/post_preview.dart';
33
import 'package:habr_app/stores/filters_store.dart';
44
import 'package:habr_app/utils/filters/article_preview_filters.dart';
55
import 'package:habr_app/utils/log.dart';
6+
import 'package:habr_app/widgets/adaptive_ui.dart';
67
import 'package:itertools/itertools.dart';
78
import 'package:hive/hive.dart';
89
import 'package:flutter_gen/gen_l10n/app_localizations.dart';
@@ -30,9 +31,9 @@ class _FiltersPageState extends State<FiltersPage> {
3031
Widget _buildBody() {
3132
return ValueListenableBuilder<Box<Filter<PostPreview>>>(
3233
valueListenable: FiltersStorage().listenable(),
33-
builder: (context, box, child) =>
34-
ListView(
35-
children: box.values.mapIndexed<Widget>((i, filter) {
34+
builder: (context, box, child) => ListView(
35+
children: box.values
36+
.mapIndexed<Widget>((i, filter) {
3637
if (filter is NicknameAuthorFilter) {
3738
return ListTile(
3839
leading: const Icon(Icons.person_outline),
@@ -46,8 +47,10 @@ class _FiltersPageState extends State<FiltersPage> {
4647
logInfo("filter not supported");
4748
}
4849
return null;
49-
}).toList(),
50-
),
50+
})
51+
.map((e) => DefaultConstraints(child: e))
52+
.toList(),
53+
),
5154
);
5255
}
5356

@@ -131,7 +134,8 @@ class _AuthorNicknameFilterDialogState
131134
controller: nickanameControll,
132135
autofocus: true,
133136
decoration: InputDecoration(
134-
labelText: AppLocalizations.of(context).authorNickname, hintText: AppLocalizations.of(context).authorNicknameHint),
137+
labelText: AppLocalizations.of(context).authorNickname,
138+
hintText: AppLocalizations.of(context).authorNicknameHint),
135139
),
136140
)
137141
],
@@ -146,8 +150,8 @@ class _AuthorNicknameFilterDialogState
146150
child: Text(AppLocalizations.of(context).create),
147151
onPressed: () {
148152
if (nicknameValid())
149-
FiltersStorage().addFilter(
150-
NicknameAuthorFilter(nickanameControll.text));
153+
FiltersStorage()
154+
.addFilter(NicknameAuthorFilter(nickanameControll.text));
151155
Navigator.pop(context);
152156
})
153157
],

lib/pages/search.dart

Lines changed: 45 additions & 38 deletions
Original file line numberDiff line numberDiff line change
@@ -38,50 +38,57 @@ class _SearchPageState extends State<SearchPage> {
3838
@override
3939
Widget build(BuildContext context) {
4040
return Scaffold(
41-
resizeToAvoidBottomInset: false,
42-
appBar: AppBar(
43-
title: Text(AppLocalizations.of(context).search),
44-
actions: [],
45-
),
46-
body: Column(children: [
41+
resizeToAvoidBottomInset: false,
42+
appBar: AppBar(
43+
title: Text(AppLocalizations.of(context).search),
44+
actions: [],
45+
),
46+
body: Column(
47+
children: [
4748
Expanded(
48-
child: ListView(
49-
children: [
50-
Card(
51-
child: Container(
52-
padding: EdgeInsets.all(10),
53-
child: TextFormField(
54-
textInputAction: TextInputAction.search,
55-
onFieldSubmitted: (_) => _onSearch(),
56-
autofocus: true,
57-
controller: queryController,
58-
decoration: InputDecoration(
59-
labelText: AppLocalizations.of(context).keywords,
60-
suffixIcon: IconButton(
61-
icon: const Icon(Icons.clear),
62-
onPressed: () {
63-
queryController.clear();
64-
},
49+
child: ListView(
50+
children: [
51+
Card(
52+
child: Container(
53+
padding: EdgeInsets.all(10),
54+
child: TextFormField(
55+
textInputAction: TextInputAction.search,
56+
onFieldSubmitted: (_) => _onSearch(),
57+
autofocus: true,
58+
controller: queryController,
59+
decoration: InputDecoration(
60+
labelText: AppLocalizations.of(context).keywords,
61+
suffixIcon: IconButton(
62+
icon: const Icon(Icons.clear),
63+
onPressed: () {
64+
queryController.clear();
65+
},
66+
),
6567
),
6668
),
6769
),
6870
),
69-
),
70-
RadioGroup<Order>(
71-
groupValue: orderBy,
72-
title: AppLocalizations.of(context).sort,
73-
enumToText: {
74-
Order.Relevance: AppLocalizations.of(context).relevance,
75-
Order.Date: AppLocalizations.of(context).date,
76-
Order.Rating: AppLocalizations.of(context).rating,
77-
},
78-
),
79-
],
80-
)),
81-
Container(
71+
RadioGroup<Order>(
72+
groupValue: orderBy,
73+
title: AppLocalizations.of(context).sort,
74+
enumToText: {
75+
Order.Relevance: AppLocalizations.of(context).relevance,
76+
Order.Date: AppLocalizations.of(context).date,
77+
Order.Rating: AppLocalizations.of(context).rating,
78+
},
79+
),
80+
].map((e) => DefaultConstraints(child: e)).toList(),
81+
),
82+
),
83+
DefaultConstraints(
84+
child: Container(
8285
padding: EdgeInsets.all(5),
83-
child: SearchButton(onPressed: _onSearch)),
84-
]));
86+
child: SearchButton(onPressed: _onSearch),
87+
),
88+
),
89+
],
90+
),
91+
);
8592
}
8693
}
8794

0 commit comments

Comments
 (0)