develop-polls #93
@@ -1,5 +1,4 @@
|
|||||||
|
|
||||||
import 'package:flutter/cupertino.dart';
|
|
||||||
import 'package:flutter/material.dart';
|
import 'package:flutter/material.dart';
|
||||||
import 'package:flutter_linkify/flutter_linkify.dart';
|
import 'package:flutter_linkify/flutter_linkify.dart';
|
||||||
|
|
||||||
@@ -16,22 +15,20 @@ class PollOptionsList extends StatefulWidget {
|
|||||||
class _PollOptionsListState extends State<PollOptionsList> {
|
class _PollOptionsListState extends State<PollOptionsList> {
|
||||||
@override
|
@override
|
||||||
Widget build(BuildContext context) => Column(
|
Widget build(BuildContext context) => Column(
|
||||||
mainAxisSize: MainAxisSize.min,
|
mainAxisSize: MainAxisSize.min,
|
||||||
children: [
|
children: [
|
||||||
...widget.pollData.options.map<Widget>((option) {
|
...widget.pollData.options.map<Widget>((option) {
|
||||||
var optionId = widget.pollData.options.indexOf(option);
|
var optionId = widget.pollData.options.indexOf(option);
|
||||||
var votedSelf = widget.pollData.votedSelf.contains(optionId);
|
var votedSelf = widget.pollData.votedSelf.contains(optionId);
|
||||||
var votes = widget.pollData.votes.runtimeType is Map<String, dynamic>
|
var portionsVisible = widget.pollData.votes is Map<String, dynamic>;
|
||||||
? widget.pollData.votes['option-$optionId']
|
var votes = !portionsVisible ? 0
|
||||||
: 0;
|
: (widget.pollData.votes['option-$optionId'] as num?) ?? 0;
|
||||||
|
Pupsi marked this conversation as resolved
Outdated
|
|||||||
int numVoters = 1;
|
var numVoters = widget.pollData.numVoters ?? 0;
|
||||||
if(widget.pollData.numVoters != null && widget.pollData.numVoters != 0) {
|
double portion = numVoters == 0 ? 0 : (votes / numVoters);
|
||||||
numVoters = widget.pollData.numVoters!;
|
|
||||||
}
|
|
||||||
var portion = (votes / numVoters);
|
|
||||||
return ListTile(
|
return ListTile(
|
||||||
enabled: false,
|
enabled: false,
|
||||||
isThreeLine: true,
|
isThreeLine: portionsVisible,
|
||||||
title: Text(
|
title: Text(
|
||||||
option,
|
option,
|
||||||
style: Theme.of(context).textTheme.bodyLarge,
|
style: Theme.of(context).textTheme.bodyLarge,
|
||||||
@@ -43,11 +40,11 @@ class _PollOptionsListState extends State<PollOptionsList> {
|
|||||||
: Theme.of(context).colorScheme.onSurfaceVariant.withValues(alpha: 0.8),
|
: Theme.of(context).colorScheme.onSurfaceVariant.withValues(alpha: 0.8),
|
||||||
),
|
),
|
||||||
subtitle: Visibility(
|
subtitle: Visibility(
|
||||||
visible: widget.pollData.numVoters != null,
|
visible: portionsVisible,
|
||||||
child: Row(
|
child: Row(
|
||||||
children: [
|
children: [
|
||||||
Expanded(
|
Expanded(
|
||||||
child: LinearProgressIndicator(value: portion),
|
child: LinearProgressIndicator(value: portion.clamp(0.0, 1.0)),
|
||||||
),
|
),
|
||||||
Container(
|
Container(
|
||||||
margin: const EdgeInsets.only(left: 10),
|
margin: const EdgeInsets.only(left: 10),
|
||||||
@@ -60,8 +57,8 @@ class _PollOptionsListState extends State<PollOptionsList> {
|
|||||||
}),
|
}),
|
||||||
ListTile(
|
ListTile(
|
||||||
title: Linkify(
|
title: Linkify(
|
||||||
text: 'Zurzeit kann in dieser App leider nicht an Abstimmungen teilgenommen werden. '
|
text: 'Zurzeit kann in dieser App leider nicht abgestimmt werden. '
|
||||||
'Um abzustimmen verwende die Webversion unter https://cloud.marianum-fulda.de',
|
'Verwende dafür die Webversion unter https://cloud.marianum-fulda.de',
|
||||||
style: Theme.of(context).textTheme.bodySmall,
|
style: Theme.of(context).textTheme.bodySmall,
|
||||||
),
|
),
|
||||||
)
|
)
|
||||||
|
|||||||
Reference in New Issue
Block a user
format ist komisch