Skip to content

Commit

Permalink
Fix password profile selector on tiny screens
Browse files Browse the repository at this point in the history
  • Loading branch information
luckyrat committed Nov 24, 2022
1 parent 5a9cba3 commit 5810bcd
Showing 1 changed file with 58 additions and 24 deletions.
82 changes: 58 additions & 24 deletions lib/widgets/password_generator.dart
Original file line number Diff line number Diff line change
Expand Up @@ -172,37 +172,71 @@ class _PasswordGeneratorWidgetState extends State<PasswordGeneratorWidget> with
child: Row(
crossAxisAlignment: CrossAxisAlignment.center,
mainAxisAlignment: MainAxisAlignment.spaceBetween,
mainAxisSize: MainAxisSize.min,
children: [
Padding(
padding: const EdgeInsets.only(right: 12.0),
child: Text(_str.preset),
),
DropdownButton<String>(
value: generatorState.current.name,
items: <DropdownMenuItem<String>>[
...generatorState.enabled.map((p) => DropdownMenuItem(
value: p.name,
child: Text(p.title),
))
],
onChanged: (value) {
if (value == null) return;
final cubit = BlocProvider.of<GeneratorProfilesCubit>(context);
final newProfile = cubit.changeCurrentProfile(value);
if (newProfile != null) {
_includeTextController.value = TextEditingValue(
text: newProfile.current.include,
selection: TextSelection.collapsed(offset: newProfile.current.include.length));
}
},
Flexible(
child: Padding(
padding: const EdgeInsets.only(right: 16.0),
child: Column(
crossAxisAlignment: CrossAxisAlignment.start,
children: [
DropdownButton<String>(
isExpanded: true,
itemHeight: null,
value: generatorState.current.name,
items: <DropdownMenuItem<String>>[
...generatorState.enabled.map((p) => DropdownMenuItem(
value: p.name,
child: Text(
p.title,
),
))
],
selectedItemBuilder: (BuildContext context) {
return generatorState.enabled
.map(
(p) => Align(
alignment: Alignment.centerLeft,
child: Text(
p.title,
overflow: TextOverflow.ellipsis,
),
),
)
.toList();
},
onChanged: (value) {
if (value == null) return;
final cubit = BlocProvider.of<GeneratorProfilesCubit>(context);
final newProfile = cubit.changeCurrentProfile(value);
if (newProfile != null) {
_includeTextController.value = TextEditingValue(
text: newProfile.current.include,
selection: TextSelection.collapsed(offset: newProfile.current.include.length));
}
},
),
],
),
),
),
OutlinedButton(
onPressed: () async => await AppConfig.router.navigateTo(
context,
Routes.passwordPresetManager,
transition: TransitionType.inFromRight,
Align(
alignment: Alignment.centerRight,
child: ConstrainedBox(
constraints: const BoxConstraints(minWidth: 150),
child: OutlinedButton(
onPressed: () async => await AppConfig.router.navigateTo(
context,
Routes.passwordPresetManager,
transition: TransitionType.inFromRight,
),
child: Text(_str.managePresets),
),
),
child: Text(_str.managePresets),
)
],
),
Expand Down

0 comments on commit 5810bcd

Please sign in to comment.