- Enabled `provider` and `shared_preferences` extensions in `devtools_options.yaml`. - Added logging for message object data on chat bubble tap. - Fixed layout issues in poll dialog by wrapping `LoadingSpinner` in a `Column` and changing `ListView` to a `Column` in `pollOptionsList.dart`. - Updated poll submission button to wait for the poll state to load before allowing interaction.
47 lines
1.3 KiB
Dart
47 lines
1.3 KiB
Dart
import 'package:flutter/cupertino.dart';
|
|
import 'package:flutter/material.dart';
|
|
|
|
import '../../../../api/marianumcloud/talk/getPoll/getPollStateResponse.dart';
|
|
|
|
class PollOptionsList extends StatefulWidget {
|
|
final GetPollStateResponseObject pollData;
|
|
final Function(List<int>) callback;
|
|
const PollOptionsList({super.key, required this.pollData, required this.callback});
|
|
|
|
@override
|
|
State<PollOptionsList> createState() => _PollOptionsListState();
|
|
}
|
|
|
|
class _PollOptionsListState extends State<PollOptionsList> {
|
|
late List<int> ownVotes;
|
|
|
|
@override
|
|
void initState() {
|
|
super.initState();
|
|
ownVotes = widget.pollData.votedSelf;
|
|
}
|
|
|
|
@override
|
|
Widget build(BuildContext context) => Column(
|
|
mainAxisSize: MainAxisSize.min,
|
|
children: [
|
|
...widget.pollData.options.map<Widget>((option) => CheckboxListTile(
|
|
value: ownVotes.contains(widget.pollData.options.indexOf(option)),
|
|
title: Text(option),
|
|
onChanged: (value) {
|
|
var optionId = widget.pollData.options.indexOf(option);
|
|
setState(() {
|
|
if(ownVotes.contains(optionId)) {
|
|
ownVotes.remove(optionId);
|
|
} else {
|
|
ownVotes.add(optionId);
|
|
}
|
|
});
|
|
widget.callback(ownVotes);
|
|
}
|
|
)
|
|
)
|
|
],
|
|
);
|
|
}
|