mirror of
https://github.com/wger-project/flutter.git
synced 2026-02-18 00:17:48 +01:00
Replace dropdown for impression with icons
This makes it more obvious and is easier and faster to use
This commit is contained in:
@@ -560,9 +560,11 @@ class _SessionPageState extends State<SessionPage> {
|
||||
final timeStartController = TextEditingController();
|
||||
final timeEndController = TextEditingController();
|
||||
|
||||
int impressionValue = 2;
|
||||
var _session = WorkoutSession();
|
||||
|
||||
/// Selected impression: bad, neutral, good
|
||||
var selectedImpression = [false, true, false];
|
||||
|
||||
@override
|
||||
void initState() {
|
||||
super.initState();
|
||||
@@ -593,25 +595,35 @@ class _SessionPageState extends State<SessionPage> {
|
||||
child: Column(
|
||||
mainAxisAlignment: MainAxisAlignment.center,
|
||||
children: [
|
||||
DropdownButtonFormField(
|
||||
value: impressionValue,
|
||||
decoration: InputDecoration(
|
||||
labelText: AppLocalizations.of(context)!.impression,
|
||||
),
|
||||
items: IMPRESSION_MAP.keys.map<DropdownMenuItem<int>>((int key) {
|
||||
return DropdownMenuItem<int>(
|
||||
value: key,
|
||||
child: Text(IMPRESSION_MAP[key]!),
|
||||
);
|
||||
}).toList(),
|
||||
onSaved: (int? newValue) {
|
||||
_session.impression = newValue!;
|
||||
},
|
||||
onChanged: (int? newValue) {
|
||||
ToggleButtons(
|
||||
children: <Widget>[
|
||||
Icon(
|
||||
Icons.sentiment_very_dissatisfied,
|
||||
),
|
||||
Icon(
|
||||
Icons.sentiment_neutral,
|
||||
),
|
||||
Icon(
|
||||
Icons.sentiment_very_satisfied,
|
||||
),
|
||||
],
|
||||
renderBorder: false,
|
||||
onPressed: (int index) {
|
||||
setState(() {
|
||||
impressionValue = newValue!;
|
||||
for (int buttonIndex = 0;
|
||||
buttonIndex < selectedImpression.length;
|
||||
buttonIndex++) {
|
||||
_session.impression = index + 1;
|
||||
|
||||
if (buttonIndex == index) {
|
||||
selectedImpression[buttonIndex] = true;
|
||||
} else {
|
||||
selectedImpression[buttonIndex] = false;
|
||||
}
|
||||
}
|
||||
});
|
||||
},
|
||||
isSelected: selectedImpression,
|
||||
),
|
||||
TextFormField(
|
||||
decoration: InputDecoration(
|
||||
@@ -650,6 +662,7 @@ class _SessionPageState extends State<SessionPage> {
|
||||
},
|
||||
),
|
||||
),
|
||||
SizedBox(width: 10),
|
||||
Flexible(
|
||||
child: TextFormField(
|
||||
decoration:
|
||||
|
||||
@@ -165,6 +165,9 @@ void main() {
|
||||
expect(find.text('Workout session'), findsOneWidget);
|
||||
expect(find.byType(SessionPage), findsOneWidget);
|
||||
expect(find.byType(Form), findsOneWidget);
|
||||
expect(find.byIcon(Icons.sentiment_dissatisfied), findsOneWidget);
|
||||
expect(find.byIcon(Icons.sentiment_neutral), findsOneWidget);
|
||||
expect(find.byIcon(Icons.sentiment_satisfied), findsOneWidget);
|
||||
expect(find.byIcon(Icons.chevron_left), findsOneWidget);
|
||||
expect(find.byIcon(Icons.close), findsOneWidget);
|
||||
expect(find.byIcon(Icons.chevron_right), findsNothing);
|
||||
|
||||
Reference in New Issue
Block a user