19 Commits

Author SHA1 Message Date
a52817231e fixed list view breaking layout 2026-02-01 17:16:42 +01:00
f6933b6529 Merge pull request 'develop-polls' (#93) from develop-polls into develop
Reviewed-on: #93
Reviewed-by: Elias Müller <elias@elias-mueller.com>
2026-02-01 14:56:23 +00:00
e4243e53ac resolved pr issues 2026-02-01 15:55:43 +01:00
0aead45191 Merge remote-tracking branch 'origin/develop' into develop-polls
# Conflicts:
#	devtools_options.yaml
2026-02-01 15:37:26 +01:00
dacefd321b updated poll list design 2026-02-01 15:35:40 +01:00
92a9a7358e changed link to directly open the chat 2026-02-01 15:20:01 +01:00
174e6ac0b7 fixed finished polls causing errors, made poll list dense 2026-02-01 15:07:48 +01:00
c9eaed782a update grade averages UI and enable devtools extensions 2026-02-01 15:06:49 +01:00
567184bcf9 filtered system messages for poll votes 2026-02-01 13:56:39 +01:00
541d6ef164 fixed issues with null values in votes map 2026-02-01 13:32:18 +01:00
3469d02033 changed poll dialog to only show results 2026-02-01 03:23:36 +01:00
699aec8ab5 Merge branch 'develop' into develop-polls 2026-02-01 00:06:51 +01:00
7a3a022ecd Merge remote-tracking branch 'origin/develop' into develop 2026-01-31 23:41:05 +01:00
9d8a99df7c added screen_brightness 2026-01-31 23:33:31 +01:00
a47e52e8e7 added screen_brightness 2026-01-31 23:31:53 +01:00
bfa0b0f5c0 feat: add devtools extensions and fix poll dialog UI/UX
- 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.
2026-01-18 10:28:17 +01:00
274b77f705 Merge branch 'develop' into develop-polls 2026-01-17 23:22:52 +01:00
b68bec9ebd WIP: add option to vote on polls 2025-10-10 11:39:57 +02:00
81f65750b7 added functionality to show own votes in polls 2025-10-10 02:01:43 +02:00
15 changed files with 336 additions and 12 deletions

View File

@@ -1 +1,4 @@
extensions: extensions:
- hive_ce: true
- shared_preferences: true
- provider: true

View File

@@ -0,0 +1,18 @@
import 'dart:convert';
import 'package:http/http.dart' as http;
import '../talkApi.dart';
import 'getPollStateResponse.dart';
class GetPollState extends TalkApi<GetPollStateResponse> {
String token;
int pollId;
GetPollState({required this.token, required this.pollId}) : super('v1/poll/$token/$pollId', null);
@override
GetPollStateResponse assemble(String raw) => GetPollStateResponse.fromJson(jsonDecode(raw)['ocs']);
@override
Future<http.Response> request(Uri uri, Object? body, Map<String, String>? headers) => http.get(uri, headers: headers);
}

View File

@@ -0,0 +1,50 @@
import 'package:json_annotation/json_annotation.dart';
import '../../../apiResponse.dart';
part 'getPollStateResponse.g.dart';
@JsonSerializable(explicitToJson: true)
class GetPollStateResponse extends ApiResponse {
GetPollStateResponseObject data;
GetPollStateResponse(this.data);
factory GetPollStateResponse.fromJson(Map<String, dynamic> json) => _$GetPollStateResponseFromJson(json);
Map<String, dynamic> toJson() => _$GetPollStateResponseToJson(this);
}
@JsonSerializable(explicitToJson: true)
class GetPollStateResponseObject {
int id;
String question;
List<String> options;
dynamic votes;
String actorType;
String actorId;
String actorDisplayName;
int status;
int resultMode;
int maxVotes;
List<int> votedSelf;
int? numVoters;
List<dynamic>? details;
GetPollStateResponseObject(
this.id,
this.question,
this.options,
this.votes,
this.actorType,
this.actorId,
this.actorDisplayName,
this.status,
this.resultMode,
this.maxVotes,
this.votedSelf,
this.numVoters,
this.details);
factory GetPollStateResponseObject.fromJson(Map<String, dynamic> json) => _$GetPollStateResponseObjectFromJson(json);
Map<String, dynamic> toJson() => _$GetPollStateResponseObjectToJson(this);
}

View File

@@ -0,0 +1,62 @@
// GENERATED CODE - DO NOT MODIFY BY HAND
part of 'getPollStateResponse.dart';
// **************************************************************************
// JsonSerializableGenerator
// **************************************************************************
GetPollStateResponse _$GetPollStateResponseFromJson(
Map<String, dynamic> json,
) =>
GetPollStateResponse(
GetPollStateResponseObject.fromJson(
json['data'] as Map<String, dynamic>,
),
)
..headers = (json['headers'] as Map<String, dynamic>?)?.map(
(k, e) => MapEntry(k, e as String),
);
Map<String, dynamic> _$GetPollStateResponseToJson(
GetPollStateResponse instance,
) => <String, dynamic>{
'headers': ?instance.headers,
'data': instance.data.toJson(),
};
GetPollStateResponseObject _$GetPollStateResponseObjectFromJson(
Map<String, dynamic> json,
) => GetPollStateResponseObject(
(json['id'] as num).toInt(),
json['question'] as String,
(json['options'] as List<dynamic>).map((e) => e as String).toList(),
json['votes'],
json['actorType'] as String,
json['actorId'] as String,
json['actorDisplayName'] as String,
(json['status'] as num).toInt(),
(json['resultMode'] as num).toInt(),
(json['maxVotes'] as num).toInt(),
(json['votedSelf'] as List<dynamic>).map((e) => (e as num).toInt()).toList(),
(json['numVoters'] as num?)?.toInt(),
json['details'] as List<dynamic>?,
);
Map<String, dynamic> _$GetPollStateResponseObjectToJson(
GetPollStateResponseObject instance,
) => <String, dynamic>{
'id': instance.id,
'question': instance.question,
'options': instance.options,
'votes': instance.votes,
'actorType': instance.actorType,
'actorId': instance.actorId,
'actorDisplayName': instance.actorDisplayName,
'status': instance.status,
'resultMode': instance.resultMode,
'maxVotes': instance.maxVotes,
'votedSelf': instance.votedSelf,
'numVoters': instance.numVoters,
'details': instance.details,
};

View File

@@ -0,0 +1,26 @@
import 'dart:convert';
import 'package:http/http.dart' as http;
import 'package:http/http.dart';
import '../getPoll/getPollStateResponse.dart';
import '../talkApi.dart';
import 'votePollParams.dart';
@Deprecated('VotePoll is broken')
class VotePoll extends TalkApi {
String token;
int pollId;
VotePoll({required this.token, required this.pollId, required VotePollParams params}) : super('v1/poll/$token/$pollId', params);
@override
GetPollStateResponse assemble(String raw) => GetPollStateResponse.fromJson(jsonDecode(raw)['ocs']);
@override
Future<Response>? request(Uri uri, Object? body, Map<String, String>? headers) {
if(body is VotePollParams) {
return http.post(uri, headers: headers, body: body.toJson().toString());
}
return null;
}
}

View File

@@ -0,0 +1,15 @@
import 'package:json_annotation/json_annotation.dart';
import '../../../apiParams.dart';
part 'votePollParams.g.dart';
@JsonSerializable()
@Deprecated('VotePoll is broken')
class VotePollParams extends ApiParams {
List<int> optionIds;
VotePollParams({required this.optionIds});
factory VotePollParams.fromJson(Map<String, dynamic> json) => _$VotePollParamsFromJson(json);
Map<String, dynamic> toJson() => _$VotePollParamsToJson(this);
}

View File

@@ -0,0 +1,17 @@
// GENERATED CODE - DO NOT MODIFY BY HAND
part of 'votePollParams.dart';
// **************************************************************************
// JsonSerializableGenerator
// **************************************************************************
VotePollParams _$VotePollParamsFromJson(Map<String, dynamic> json) =>
VotePollParams(
optionIds: (json['optionIds'] as List<dynamic>)
.map((e) => (e as num).toInt())
.toList(),
);
Map<String, dynamic> _$VotePollParamsToJson(VotePollParams instance) =>
<String, dynamic>{'optionIds': instance.optionIds};

View File

@@ -51,7 +51,7 @@ class GradeAveragesView extends StatelessWidget {
color: Theme.of(context).colorScheme.onSurface color: Theme.of(context).colorScheme.onSurface
), ),
const SizedBox(width: 15), const SizedBox(width: 15),
Text(isMiddleSchool ? 'Notensystem' : 'Punktesystem'), Text(isMiddleSchool ? 'Realschule' : 'Oberstufe'),
], ],
), ),
)).toList(), )).toList(),
@@ -80,11 +80,19 @@ class GradeAveragesView extends StatelessWidget {
mainAxisAlignment: MainAxisAlignment.center, mainAxisAlignment: MainAxisAlignment.center,
children: [ children: [
const SizedBox(height: 30), const SizedBox(height: 30),
Text(bloc.average().toStringAsFixed(2), style: const TextStyle(fontSize: 30, fontWeight: FontWeight.bold)), Row(
crossAxisAlignment: CrossAxisAlignment.center,
mainAxisAlignment: MainAxisAlignment.center,
children: [
Text('Ø', style: TextStyle(fontSize: 30, fontWeight: FontWeight.bold)),
SizedBox(width: 5),
Text(bloc.average().toStringAsFixed(2), style: const TextStyle(fontSize: 30, fontWeight: FontWeight.bold))
],
),
const SizedBox(height: 10), const SizedBox(height: 10),
const Divider(), const Divider(),
const SizedBox(height: 10), const SizedBox(height: 10),
Text(bloc.isMiddleSchool() ? 'Wähle unten die Anzahl deiner jeweiligen Noten aus' : 'Wähle unten die Anzahl deiner jeweiligen Punkte aus'), Text(bloc.isMiddleSchool() ? 'Wähle die Anzahl deiner jeweiligen Noten aus' : 'Wähle die Anzahl deiner jeweiligen Punkte aus'),
const SizedBox(height: 10), const SizedBox(height: 10),
const Expanded( const Expanded(
child: GradeAveragesListView() child: GradeAveragesListView()

10
lib/utils/UrlOpener.dart Normal file
View File

@@ -0,0 +1,10 @@
import 'package:flutter_linkify/flutter_linkify.dart';
import 'package:url_launcher/url_launcher_string.dart';
class UrlOpener {
static Future<void> onOpen(LinkableElement link) async {
if(await canLaunchUrlString(link.url)) {
await launchUrlString(link.url);
}
}
}

View File

@@ -1,4 +1,5 @@
import 'package:flutter/material.dart'; import 'package:flutter/material.dart';
import 'package:screen_brightness/screen_brightness.dart';
import 'appSharePlatformView.dart'; import 'appSharePlatformView.dart';
@@ -10,6 +11,18 @@ class QrShareView extends StatefulWidget {
} }
class _QrShareViewState extends State<QrShareView> { class _QrShareViewState extends State<QrShareView> {
@override
void initState() {
ScreenBrightness.instance.setApplicationScreenBrightness(1.0);
super.initState();
}
@override
void dispose() {
ScreenBrightness.instance.resetApplicationScreenBrightness();
super.dispose();
}
@override @override
Widget build(BuildContext context) => DefaultTabController( Widget build(BuildContext context) => DefaultTabController(
length: 2, length: 2,

View File

@@ -51,6 +51,7 @@ class _ChatViewState extends State<ChatView> {
var elementDate = DateTime.fromMillisecondsSinceEpoch(element.timestamp * 1000); var elementDate = DateTime.fromMillisecondsSinceEpoch(element.timestamp * 1000);
if(element.systemMessage.contains('reaction')) return; if(element.systemMessage.contains('reaction')) return;
if(element.systemMessage.contains('poll_voted')) return;
var commonRead = int.parse(data.getChatResponse.headers?['x-chat-last-common-read'] ?? '0'); var commonRead = int.parse(data.getChatResponse.headers?['x-chat-last-common-read'] ?? '0');
if(!elementDate.isSameDay(lastDate)) { if(!elementDate.isSameDay(lastDate)) {
@@ -128,7 +129,7 @@ class _ChatViewState extends State<ChatView> {
), ),
), ),
Container( Container(
color: Theme.of(context).colorScheme.background, color: Theme.of(context).colorScheme.surface,
child: TalkNavigator.isSecondaryVisible(context) child: TalkNavigator.isSecondaryVisible(context)
? ChatTextfield(widget.room.token, selfId: widget.selfId) ? ChatTextfield(widget.room.token, selfId: widget.selfId)
: SafeArea(child: ChatTextfield(widget.room.token, selfId: widget.selfId) : SafeArea(child: ChatTextfield(widget.room.token, selfId: widget.selfId)

View File

@@ -6,6 +6,7 @@ import 'package:flutter/material.dart';
import 'package:flutter/services.dart'; import 'package:flutter/services.dart';
import 'package:jiffy/jiffy.dart'; import 'package:jiffy/jiffy.dart';
import 'package:open_filex/open_filex.dart'; import 'package:open_filex/open_filex.dart';
import '../../../../api/marianumcloud/talk/getPoll/getPollState.dart';
import '../../../../extensions/text.dart'; import '../../../../extensions/text.dart';
import 'package:provider/provider.dart'; import 'package:provider/provider.dart';
@@ -18,11 +19,13 @@ import '../../../../api/marianumcloud/talk/reactMessage/reactMessageParams.dart'
import '../../../../api/marianumcloud/talk/room/getRoomResponse.dart'; import '../../../../api/marianumcloud/talk/room/getRoomResponse.dart';
import '../../../../model/chatList/chatProps.dart'; import '../../../../model/chatList/chatProps.dart';
import '../../../../widget/debug/debugTile.dart'; import '../../../../widget/debug/debugTile.dart';
import '../../../../widget/loadingSpinner.dart';
import '../../files/fileElement.dart'; import '../../files/fileElement.dart';
import 'answerReference.dart'; import 'answerReference.dart';
import 'chatBubbleStyles.dart'; import 'chatBubbleStyles.dart';
import 'chatMessage.dart'; import 'chatMessage.dart';
import '../messageReactions.dart'; import '../messageReactions.dart';
import 'pollOptionsList.dart';
class ChatBubble extends StatefulWidget { class ChatBubble extends StatefulWidget {
final BuildContext context; final BuildContext context;
@@ -297,6 +300,34 @@ class _ChatBubbleState extends State<ChatBubble> with SingleTickerProviderStateM
onLongPress: showOptionsDialog, onLongPress: showOptionsDialog,
onDoubleTap: showOptionsDialog, onDoubleTap: showOptionsDialog,
onTap: () { onTap: () {
if(message.originalData?['object']?.type == RichObjectStringObjectType.talkPoll) {
var pollId = int.parse(message.originalData!['object']!.id);
var pollState = GetPollState(token: widget.bubbleData.token, pollId: pollId).run();
showDialog(context: context, builder: (context) => AlertDialog(
title: Text(message.originalData!['object']!.name, overflow: TextOverflow.ellipsis),
content: FutureBuilder(
future: pollState,
builder: (context, snapshot) {
if(snapshot.connectionState == ConnectionState.waiting) return const Column(mainAxisSize: MainAxisSize.min, children: [LoadingSpinner()]);
var pollData = snapshot.data!.data;
return SingleChildScrollView(
child: PollOptionsList(
pollData: pollData,
chatToken: widget.chatData.token,
),
);
}
),
actions: [
TextButton(
onPressed: () => Navigator.of(context).pop(),
child: const Text('Zurück')
),
],
));
}
if(message.file == null) return; if(message.file == null) return;
if(downloadProgress > 0) { if(downloadProgress > 0) {

View File

@@ -2,12 +2,12 @@
import 'package:cached_network_image/cached_network_image.dart'; import 'package:cached_network_image/cached_network_image.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';
import 'package:url_launcher/url_launcher_string.dart';
import '../../../../api/marianumcloud/talk/chat/getChatResponse.dart'; import '../../../../api/marianumcloud/talk/chat/getChatResponse.dart';
import '../../../../api/marianumcloud/talk/chat/richObjectStringProcessor.dart'; import '../../../../api/marianumcloud/talk/chat/richObjectStringProcessor.dart';
import '../../../../model/accountData.dart'; import '../../../../model/accountData.dart';
import '../../../../model/endpointData.dart'; import '../../../../model/endpointData.dart';
import '../../../../utils/UrlOpener.dart';
class ChatMessage { class ChatMessage {
String originalMessage; String originalMessage;
@@ -29,9 +29,17 @@ class ChatMessage {
var contentWidget = Linkify( var contentWidget = Linkify(
text: content, text: content,
onOpen: onOpen, onOpen: UrlOpener.onOpen,
); );
if(originalData?['object']?.type == RichObjectStringObjectType.talkPoll) {
return ListTile(
leading: const Icon(Icons.poll_outlined),
title: Text(originalData!['object']!.name),
contentPadding: const EdgeInsets.only(left: 10),
);
}
if(file == null) return contentWidget; if(file == null) return contentWidget;
return Padding( return Padding(
@@ -65,10 +73,4 @@ class ChatMessage {
) )
); );
} }
Future<void> onOpen(LinkableElement link) async {
if(await canLaunchUrlString(link.url)) {
await launchUrlString(link.url);
}
}
} }

View File

@@ -0,0 +1,67 @@
import 'package:flutter/material.dart';
import 'package:flutter_linkify/flutter_linkify.dart';
import '../../../../api/marianumcloud/talk/getPoll/getPollStateResponse.dart';
import '../../../../utils/UrlOpener.dart';
class PollOptionsList extends StatefulWidget {
final GetPollStateResponseObject pollData;
final String chatToken;
const PollOptionsList({super.key, required this.pollData, required this.chatToken});
@override
State<PollOptionsList> createState() => _PollOptionsListState();
}
class _PollOptionsListState extends State<PollOptionsList> {
@override
Widget build(BuildContext context) => Column(
children: [
...widget.pollData.options.map<Widget>((option) {
var optionId = widget.pollData.options.indexOf(option);
var votedSelf = widget.pollData.votedSelf.contains(optionId);
var portionsVisible = widget.pollData.votes is Map<String, dynamic>;
var votes = portionsVisible
? (widget.pollData.votes['option-$optionId'] as num?) ?? 0
: 0;
var numVoters = widget.pollData.numVoters ?? 0;
double portion = numVoters == 0 ? 0 : (votes / numVoters);
return ListTile(
// enabled: false,
isThreeLine: portionsVisible,
dense: true,
title: Text(
option,
style: Theme.of(context).textTheme.bodyLarge,
),
leading: Icon(
votedSelf ? Icons.check_circle_outlined : Icons.circle_outlined,
color: votedSelf
? Theme.of(context).colorScheme.primary.withValues(alpha: 0.6)
: Theme.of(context).colorScheme.onSurfaceVariant.withValues(alpha: 0.6),
),
subtitle: portionsVisible ? Row(
children: [
Expanded(
child: LinearProgressIndicator(value: portion.clamp(0.0, 1.0)),
),
Container(
margin: const EdgeInsets.only(left: 10),
child: Text('${(portion * 100).round()}%'),
),
],
) : null,
);
}),
ListTile(
title: Linkify(
text: 'Wenn du abstimmen möchtest, verwende die Webversion unter https://cloud.marianum-fulda.de/call/${widget.chatToken}',
onOpen: UrlOpener.onOpen,
style: Theme.of(context).textTheme.bodySmall,
),
)
],
);
}

View File

@@ -72,6 +72,7 @@ dependencies:
qr_flutter: ^4.1.0 qr_flutter: ^4.1.0
rrule: ^0.2.17 rrule: ^0.2.17
rrule_generator: ^0.9.0 rrule_generator: ^0.9.0
screen_brightness: ^2.1.7
share_plus: ^11.1.0 share_plus: ^11.1.0
shared_preferences: ^2.3.5 shared_preferences: ^2.3.5
syncfusion_flutter_calendar: ^31.1.17 syncfusion_flutter_calendar: ^31.1.17