Skip to content

Commit 825c5f7

Browse files
committed
Set fixed countries dropdown width in filters
Make the filters repo resetting after changing items type
1 parent 3e32b55 commit 825c5f7

File tree

5 files changed

+19
-20
lines changed

5 files changed

+19
-20
lines changed

lib/ui/database_item_editors/hill_editor.dart

Lines changed: 15 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,7 @@ import 'package:sj_manager/ui/reusable_widgets/database_item_images/hill_image/h
2323
import 'package:sj_manager/ui/reusable_widgets/database_item_images/item_image_not_found_placeholder.dart';
2424
import 'package:sj_manager/ui/reusable_widgets/menu_entries/predefined_reusable_entries.dart';
2525
import 'package:sj_manager/utils/context_maybe_read.dart';
26+
import 'package:sj_manager/utils/math.dart';
2627
import 'package:sj_manager/utils/platform.dart';
2728

2829
class HillEditor extends StatefulWidget {
@@ -70,7 +71,6 @@ class HillEditorState extends State<HillEditor> {
7071

7172
Hill? _cachedHill;
7273

73-
final _firstFocusNode = FocusNode();
7474
late final ScrollController _scrollController;
7575

7676
@override
@@ -105,7 +105,6 @@ class HillEditorState extends State<HillEditor> {
105105
_profileController.dispose();
106106
_jumpsVariabilityController.dispose();
107107
_typicalWindDirectionController.dispose();
108-
_firstFocusNode.dispose();
109108
_scrollController.dispose();
110109
super.dispose();
111110
}
@@ -139,7 +138,6 @@ class HillEditorState extends State<HillEditor> {
139138
MyTextField(
140139
key: const Key('name'),
141140
enabled: widget.enableEditingName,
142-
focusNode: _firstFocusNode,
143141
controller: _nameController,
144142
onChange: () {
145143
widget.onChange(_constructAndCacheHill());
@@ -160,13 +158,18 @@ class HillEditorState extends State<HillEditor> {
160158
labelText: translate(context).locality,
161159
),
162160
gap,
163-
CountriesDropdown(
164-
enabled: widget.enableEditingCountry,
165-
key: _countriesDropdownKey,
166-
countriesApi: RepositoryProvider.of<CountriesRepo>(context),
167-
onSelected: (maybeCountry) {
168-
_country = maybeCountry;
169-
widget.onChange(_constructAndCacheHill());
161+
LayoutBuilder(
162+
builder: (context, constraints) {
163+
return CountriesDropdown(
164+
enabled: widget.enableEditingCountry,
165+
width: constraints.maxWidth,
166+
key: _countriesDropdownKey,
167+
countriesApi: RepositoryProvider.of<CountriesRepo>(context),
168+
onSelected: (maybeCountry) {
169+
_country = maybeCountry;
170+
widget.onChange(_constructAndCacheHill());
171+
},
172+
);
170173
},
171174
),
172175
gap,
@@ -363,10 +366,11 @@ class HillEditorState extends State<HillEditor> {
363366
TextButton(
364367
onPressed: () {
365368
if (_cachedHill != null) {
366-
final double autoTailwind = _cachedHill!.pointsForHeadwind *
369+
var autoTailwind = _cachedHill!.pointsForHeadwind *
367370
context
368371
.read<DbEditingDefaultsRepo>()
369372
.autoPointsForTailwindMultiplier;
373+
autoTailwind = roundToNDecimalPlaces(autoTailwind, 2);
370374
_pointsForTailwindController.text = autoTailwind.toString();
371375

372376
widget.onChange(
@@ -421,7 +425,6 @@ class HillEditorState extends State<HillEditor> {
421425
});
422426
_fillFields(hill);
423427
FocusScope.of(context).unfocus();
424-
FocusScope.of(context).requestFocus(_firstFocusNode);
425428
}
426429

427430
void _fillFields(Hill hill) {

lib/ui/database_item_editors/jumper_editor.dart

Lines changed: 0 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,3 @@
1-
import 'dart:async';
2-
31
import 'package:flutter/material.dart';
42
import 'package:flutter/services.dart';
53
import 'package:flutter_bloc/flutter_bloc.dart';
@@ -68,8 +66,6 @@ class JumperEditorState extends State<JumperEditor> {
6866
Country? _country;
6967

7068
Jumper? _cachedJumper;
71-
72-
final _firstFocusNode = FocusNode();
7369
late final ScrollController _scrollController;
7470

7571
@override
@@ -94,7 +90,6 @@ class JumperEditorState extends State<JumperEditor> {
9490
_qualityOnLargerHillsController.dispose();
9591
_jumpsConsistencyController.dispose();
9692
_landingStyleController.dispose();
97-
_firstFocusNode.dispose();
9893
_scrollController.dispose();
9994
super.dispose();
10095
}
@@ -125,7 +120,6 @@ class JumperEditorState extends State<JumperEditor> {
125120
crossAxisAlignment: CrossAxisAlignment.start,
126121
children: [
127122
MyTextField(
128-
//focusNode: _firstFocusNode,
129123
enabled: widget.enableEditingName,
130124
controller: _nameController,
131125
onChange: _onChange,
@@ -294,7 +288,6 @@ class JumperEditorState extends State<JumperEditor> {
294288
});
295289
_fillFields(jumper);
296290
FocusScope.of(context).unfocus();
297-
FocusScope.of(context).requestFocus(_firstFocusNode);
298291
}
299292

300293
void _fillFields(Jumper jumper) {

lib/ui/screens/database_editor/large/__large.dart

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -265,8 +265,9 @@ class _LargeState extends State<_Large> with SingleTickerProviderStateMixin {
265265
}
266266

267267
Future<void> _onChangeTab(int index) async {
268-
_itemsTypeCubit.select(DatabaseItemType.fromIndex(index));
269268
_selectedIndexesRepo.clearSelection();
269+
_filtersRepo.clear();
270+
_itemsTypeCubit.select(DatabaseItemType.fromIndex(index));
270271
if (index != _currentTabIndex) {
271272
await _animateBodyFromZero();
272273
_currentTabIndex = index;

lib/ui/screens/database_editor/large/widgets/filters/__for_hills.dart

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -51,6 +51,7 @@ class _ForHillsState extends State<_ForHills> {
5151
),
5252
gap,
5353
CountriesDropdown(
54+
width: 220,
5455
label: Text(translate(context).filterByCountry),
5556
countriesApi: context.read(),
5657
firstAsInitial: true,

lib/ui/screens/database_editor/large/widgets/filters/__for_jumpers.dart

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -31,6 +31,7 @@ class _ForJumpersState extends State<_ForJumpers> {
3131
),
3232
const Spacer(),
3333
CountriesDropdown(
34+
width: 220,
3435
label: Text(translate(context).filterByCountry),
3536
countriesApi: context.read(),
3637
firstAsInitial: true,

0 commit comments

Comments
 (0)