improve unsupported media and sensitive threads
This commit is contained in:
parent
c6fe34e66e
commit
cb81269576
|
@ -1,43 +1,26 @@
|
||||||
import 'package:flutter/material.dart';
|
import 'package:flutter/material.dart';
|
||||||
|
import 'package:localization/localization.dart';
|
||||||
|
import 'package:loris/business_logic/timeline/timeline.dart';
|
||||||
import '../business_logic/posting/posting.dart' as logic;
|
import '../business_logic/posting/posting.dart' as logic;
|
||||||
|
|
||||||
class MakePost extends StatelessWidget {
|
class MakePost extends StatefulWidget {
|
||||||
const MakePost({Key? key}) : super(key: key);
|
const MakePost({Key? key, this.inReplyTo}) : super(key: key);
|
||||||
|
final PostModel? inReplyTo;
|
||||||
|
|
||||||
|
@override
|
||||||
|
State<MakePost> createState() => _MakePostState();
|
||||||
|
}
|
||||||
|
|
||||||
|
class _MakePostState extends State<MakePost> {
|
||||||
@override
|
@override
|
||||||
Widget build(BuildContext context) {
|
Widget build(BuildContext context) {
|
||||||
return SimpleDialog(
|
return SimpleDialog(
|
||||||
backgroundColor: Theme.of(context).colorScheme.background,
|
alignment: Alignment.center,
|
||||||
elevation: 0,
|
title: SelectableText(
|
||||||
contentPadding: const EdgeInsets.all(24),
|
textAlign: TextAlign.center,
|
||||||
insetPadding: const EdgeInsets.all(24),
|
widget.inReplyTo == null ? "make-post".i18n() : "make-reply".i18n(),
|
||||||
children: [
|
style: Theme.of(context).textTheme.displayMedium),
|
||||||
TextFormField(
|
children: [],
|
||||||
autofocus: true,
|
|
||||||
keyboardType: TextInputType.multiline,
|
|
||||||
minLines: 4,
|
|
||||||
maxLines: null,
|
|
||||||
),
|
|
||||||
const MakePostActionBar(),
|
|
||||||
],
|
|
||||||
);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
class MakePostActionBar extends StatelessWidget {
|
|
||||||
const MakePostActionBar({Key? key}) : super(key: key);
|
|
||||||
|
|
||||||
@override
|
|
||||||
Widget build(BuildContext context) {
|
|
||||||
return Row(
|
|
||||||
children: [
|
|
||||||
IconButton(
|
|
||||||
onPressed: () {
|
|
||||||
Navigator.of(context).pop();
|
|
||||||
},
|
|
||||||
icon: const Icon(Icons.cancel),
|
|
||||||
),
|
|
||||||
],
|
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -47,6 +47,8 @@
|
||||||
"unlisted-visibility": "unlisted",
|
"unlisted-visibility": "unlisted",
|
||||||
"public-visibility": "public",
|
"public-visibility": "public",
|
||||||
"private-visibility": "private",
|
"private-visibility": "private",
|
||||||
"direct-visibility": "dm"
|
"direct-visibility": "dm",
|
||||||
|
"make-reply": "make reply",
|
||||||
|
"make-post": "make post"
|
||||||
}
|
}
|
||||||
|
|
|
@ -184,11 +184,16 @@ class _InteractionButtonState extends State<InteractionButton> {
|
||||||
await showModalBottomSheet(
|
await showModalBottomSheet(
|
||||||
context: context,
|
context: context,
|
||||||
builder: ((context) {
|
builder: ((context) {
|
||||||
|
SizedBox box = const SizedBox(
|
||||||
|
height: 24,
|
||||||
|
);
|
||||||
List<Widget> c = [
|
List<Widget> c = [
|
||||||
|
box,
|
||||||
SelectableText(
|
SelectableText(
|
||||||
widget.type.name,
|
widget.type.name,
|
||||||
style: Theme.of(context).textTheme.displayLarge,
|
style: Theme.of(context).textTheme.displayLarge,
|
||||||
)
|
),
|
||||||
|
box
|
||||||
];
|
];
|
||||||
idList.forEach(
|
idList.forEach(
|
||||||
(key, value) {
|
(key, value) {
|
||||||
|
@ -231,6 +236,7 @@ class _InteractionButtonState extends State<InteractionButton> {
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
);
|
);
|
||||||
|
c.add(box);
|
||||||
return SingleChildScrollView(
|
return SingleChildScrollView(
|
||||||
child: Column(
|
child: Column(
|
||||||
mainAxisAlignment: MainAxisAlignment.center,
|
mainAxisAlignment: MainAxisAlignment.center,
|
||||||
|
|
|
@ -1,6 +1,7 @@
|
||||||
import 'package:flutter/material.dart';
|
import 'package:flutter/material.dart';
|
||||||
import 'package:localization/localization.dart';
|
import 'package:localization/localization.dart';
|
||||||
import 'package:loris/business_logic/timeline/media.dart';
|
import 'package:loris/business_logic/timeline/media.dart';
|
||||||
|
import 'package:url_launcher/url_launcher_string.dart';
|
||||||
|
|
||||||
class MediaAttachments extends StatelessWidget {
|
class MediaAttachments extends StatelessWidget {
|
||||||
const MediaAttachments({required this.models, Key? key}) : super(key: key);
|
const MediaAttachments({required this.models, Key? key}) : super(key: key);
|
||||||
|
@ -12,7 +13,12 @@ class MediaAttachments extends StatelessWidget {
|
||||||
if (models[i].type == "image" || models[i].type == "gif") {
|
if (models[i].type == "image" || models[i].type == "gif") {
|
||||||
children.add(ImageAttachmentDisplay(model: models[i]));
|
children.add(ImageAttachmentDisplay(model: models[i]));
|
||||||
} else {
|
} else {
|
||||||
children.add(Text("media-not-supported".i18n()));
|
children.add(TextButton.icon(
|
||||||
|
onPressed: () {
|
||||||
|
launchUrlString(models[i].url);
|
||||||
|
},
|
||||||
|
icon: const Icon(Icons.open_in_browser),
|
||||||
|
label: Text("open-media-in-browser".i18n())));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -2,6 +2,7 @@ import 'package:flutter/material.dart';
|
||||||
import 'package:localization/localization.dart';
|
import 'package:localization/localization.dart';
|
||||||
import 'package:loris/business_logic/account/account.dart';
|
import 'package:loris/business_logic/account/account.dart';
|
||||||
import 'package:loris/business_logic/timeline/media.dart';
|
import 'package:loris/business_logic/timeline/media.dart';
|
||||||
|
import 'package:loris/dialogues/makepost.dart';
|
||||||
import 'package:loris/partials/interaction_button.dart';
|
import 'package:loris/partials/interaction_button.dart';
|
||||||
import 'package:loris/partials/media_attachment.dart';
|
import 'package:loris/partials/media_attachment.dart';
|
||||||
import 'package:loris/partials/post_options.dart';
|
import 'package:loris/partials/post_options.dart';
|
||||||
|
@ -268,8 +269,19 @@ class _PostActionBarState extends State<PostActionBar> {
|
||||||
mainAxisAlignment: MainAxisAlignment.spaceAround,
|
mainAxisAlignment: MainAxisAlignment.spaceAround,
|
||||||
children: [
|
children: [
|
||||||
Expanded(
|
Expanded(
|
||||||
flex: 20,
|
flex: 20,
|
||||||
child: IconButton(onPressed: () {}, icon: const Icon(Icons.reply))),
|
child: IconButton(
|
||||||
|
onPressed: () {
|
||||||
|
showDialog(
|
||||||
|
context: context,
|
||||||
|
builder: ((context) => MakePost(
|
||||||
|
inReplyTo: widget.model,
|
||||||
|
)));
|
||||||
|
},
|
||||||
|
icon: const Icon(Icons.reply),
|
||||||
|
tooltip: "reply".i18n(),
|
||||||
|
),
|
||||||
|
),
|
||||||
Expanded(
|
Expanded(
|
||||||
flex: 20,
|
flex: 20,
|
||||||
child: InteractionButton(
|
child: InteractionButton(
|
||||||
|
@ -287,6 +299,7 @@ class _PostActionBarState extends State<PostActionBar> {
|
||||||
Expanded(
|
Expanded(
|
||||||
flex: 20,
|
flex: 20,
|
||||||
child: IconButton(
|
child: IconButton(
|
||||||
|
tooltip: "post-options".i18n(),
|
||||||
onPressed: () {
|
onPressed: () {
|
||||||
popupPostOptions(context, widget.model);
|
popupPostOptions(context, widget.model);
|
||||||
},
|
},
|
||||||
|
|
|
@ -13,7 +13,8 @@ class Thread extends StatefulWidget {
|
||||||
}
|
}
|
||||||
|
|
||||||
class _ThreadState extends State<Thread> {
|
class _ThreadState extends State<Thread> {
|
||||||
bool anySensitivePosts = false;
|
Set<String> contentWarnings = {};
|
||||||
|
int sensitivePosts = 0;
|
||||||
bool showSensitive = false;
|
bool showSensitive = false;
|
||||||
|
|
||||||
@override
|
@override
|
||||||
|
@ -25,16 +26,32 @@ class _ThreadState extends State<Thread> {
|
||||||
hideSensitive: !showSensitive,
|
hideSensitive: !showSensitive,
|
||||||
));
|
));
|
||||||
if (element.sensitive) {
|
if (element.sensitive) {
|
||||||
anySensitivePosts = true;
|
sensitivePosts += 1;
|
||||||
|
contentWarnings.add(element.spoilerText);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (anySensitivePosts && c.length > 1) {
|
if (sensitivePosts > 1 && c.length > 1) {
|
||||||
|
String s = "";
|
||||||
|
int i = 0;
|
||||||
|
for (var element in contentWarnings) {
|
||||||
|
if (i == 0) {
|
||||||
|
s = "$element;";
|
||||||
|
} else if (i < contentWarnings.length - 1) {
|
||||||
|
s = "$s $element;";
|
||||||
|
} else {
|
||||||
|
s = "$s $element";
|
||||||
|
}
|
||||||
|
i++;
|
||||||
|
}
|
||||||
c.insert(
|
c.insert(
|
||||||
0,
|
0,
|
||||||
Row(
|
Row(
|
||||||
mainAxisAlignment: MainAxisAlignment.end,
|
mainAxisAlignment: MainAxisAlignment.end,
|
||||||
children: [
|
children: [
|
||||||
|
Expanded(
|
||||||
|
child: SelectableText(s),
|
||||||
|
),
|
||||||
OutlinedButton.icon(
|
OutlinedButton.icon(
|
||||||
onPressed: () {
|
onPressed: () {
|
||||||
setState(() {
|
setState(() {
|
||||||
|
|
Loading…
Reference in New Issue