🐛 Bug fixes
This commit is contained in:
@@ -14,6 +14,7 @@ import 'package:island/models/embed.dart';
|
||||
import 'package:island/pods/call.dart';
|
||||
import 'package:island/pods/translate.dart';
|
||||
import 'package:island/screens/chat/room.dart';
|
||||
import 'package:island/utils/mapping.dart';
|
||||
import 'package:island/widgets/account/account_name.dart';
|
||||
import 'package:island/widgets/account/account_pfc.dart';
|
||||
import 'package:island/widgets/app_scaffold.dart';
|
||||
@@ -292,12 +293,11 @@ class MessageItem extends HookConsumerWidget {
|
||||
),
|
||||
if (remoteMessage.meta['embeds'] != null)
|
||||
...((remoteMessage.meta['embeds'] as List<dynamic>)
|
||||
.where((embed) => embed['Type'] == 'link')
|
||||
.map(
|
||||
(embed) => SnEmbedLink.fromJson(
|
||||
embed as Map<String, dynamic>,
|
||||
),
|
||||
(embed) => convertMapKeysToSnakeCase(embed),
|
||||
)
|
||||
.where((embed) => embed['type'] == 'link')
|
||||
.map((embed) => SnScrappedLink.fromJson(embed))
|
||||
.map(
|
||||
(link) => LayoutBuilder(
|
||||
builder: (context, constraints) {
|
||||
|
@@ -1,5 +1,4 @@
|
||||
import 'dart:math' as math;
|
||||
import 'dart:ui';
|
||||
|
||||
import 'package:cached_network_image/cached_network_image.dart';
|
||||
import 'package:flutter/material.dart';
|
||||
|
@@ -6,7 +6,7 @@ import 'package:material_symbols_icons/symbols.dart';
|
||||
import 'package:url_launcher/url_launcher.dart';
|
||||
|
||||
class EmbedLinkWidget extends StatelessWidget {
|
||||
final SnEmbedLink link;
|
||||
final SnScrappedLink link;
|
||||
final double? maxWidth;
|
||||
final EdgeInsetsGeometry? margin;
|
||||
|
||||
@@ -116,7 +116,8 @@ class EmbedLinkWidget extends StatelessWidget {
|
||||
],
|
||||
|
||||
// Description
|
||||
if (link.description != null && link.description!.isNotEmpty) ...[
|
||||
if (link.description != null &&
|
||||
link.description!.isNotEmpty) ...[
|
||||
Text(
|
||||
link.description!,
|
||||
style: theme.textTheme.bodyMedium?.copyWith(
|
||||
@@ -191,7 +192,7 @@ class EmbedLinkWidget extends StatelessWidget {
|
||||
try {
|
||||
final now = DateTime.now();
|
||||
final difference = now.difference(date);
|
||||
|
||||
|
||||
if (difference.inDays == 0) {
|
||||
return 'Today';
|
||||
} else if (difference.inDays == 1) {
|
||||
|
@@ -3,21 +3,6 @@ import 'package:flutter_riverpod/flutter_riverpod.dart';
|
||||
import 'package:island/models/poll.dart';
|
||||
import 'package:island/pods/network.dart';
|
||||
|
||||
/// A poll answering widget that shows one question at a time and collects answers.
|
||||
///
|
||||
/// Usage:
|
||||
/// PollSubmit(
|
||||
/// poll: poll,
|
||||
/// onSubmit: (answers) {
|
||||
/// // answers is Map<String, dynamic>: questionId -> answer
|
||||
/// // answer types by question:
|
||||
/// // - singleChoice: String optionId
|
||||
/// // - multipleChoice: List<String> optionIds
|
||||
/// // - yesNo: bool
|
||||
/// // - rating: int (1..5)
|
||||
/// // - freeText: String
|
||||
/// },
|
||||
/// )
|
||||
class PollSubmit extends ConsumerStatefulWidget {
|
||||
const PollSubmit({
|
||||
super.key,
|
||||
|
@@ -189,8 +189,8 @@ class ComposePollSheet extends HookConsumerWidget {
|
||||
Widget? _buildPollSubtitle(SnPoll poll) {
|
||||
try {
|
||||
final SnPoll dyn = poll;
|
||||
final List<SnPollQuestion>? options = dyn.questions;
|
||||
if (options == null || options.isEmpty) return null;
|
||||
final List<SnPollQuestion> options = dyn.questions;
|
||||
if (options.isEmpty) return null;
|
||||
final preview = options.take(3).map((e) => e.title).join(' · ');
|
||||
if (preview.trim().isEmpty) return null;
|
||||
return Text(preview);
|
||||
|
@@ -547,7 +547,9 @@ class PostItem extends HookConsumerWidget {
|
||||
...((item.meta!['embeds'] as List<dynamic>).map(
|
||||
(embedData) => switch (embedData['type']) {
|
||||
'link' => EmbedLinkWidget(
|
||||
link: SnEmbedLink.fromJson(embedData as Map<String, dynamic>),
|
||||
link: SnScrappedLink.fromJson(
|
||||
embedData as Map<String, dynamic>,
|
||||
),
|
||||
maxWidth: math.min(
|
||||
MediaQuery.of(context).size.width,
|
||||
kWideScreenWidth,
|
||||
@@ -877,38 +879,40 @@ class PostReplyPreview extends HookConsumerWidget {
|
||||
),
|
||||
],
|
||||
)
|
||||
: featuredReply!.when(
|
||||
: (featuredReply!).map(
|
||||
data:
|
||||
(value) => Row(
|
||||
(data) => Row(
|
||||
crossAxisAlignment: CrossAxisAlignment.center,
|
||||
spacing: 8,
|
||||
children: [
|
||||
ProfilePictureWidget(
|
||||
file: value?.publisher.picture,
|
||||
file: data.value?.publisher.picture,
|
||||
radius: 12,
|
||||
).padding(top: 4),
|
||||
if (value?.content?.isNotEmpty ?? false)
|
||||
if (data.value?.content?.isNotEmpty ?? false)
|
||||
Expanded(
|
||||
child: MarkdownTextContent(content: value!.content!),
|
||||
child: MarkdownTextContent(
|
||||
content: data.value!.content!,
|
||||
),
|
||||
)
|
||||
else
|
||||
Expanded(
|
||||
child: Text(
|
||||
'postHasAttachments',
|
||||
).plural(value?.attachments.length ?? 0),
|
||||
).plural(data.value?.attachments.length ?? 0),
|
||||
),
|
||||
],
|
||||
),
|
||||
error:
|
||||
(error, _) => Row(
|
||||
(e) => Row(
|
||||
spacing: 8,
|
||||
children: [
|
||||
const Icon(Symbols.close, size: 18),
|
||||
Text(error.toString()),
|
||||
Text(e.error.toString()),
|
||||
],
|
||||
),
|
||||
loading:
|
||||
() => Row(
|
||||
(_) => Row(
|
||||
spacing: 8,
|
||||
children: [
|
||||
SizedBox(
|
||||
|
Reference in New Issue
Block a user