110 lines
2.9 KiB
Dart
110 lines
2.9 KiB
Dart
import 'package:flutter/material.dart';
|
|
import 'package:localization/localization.dart';
|
|
import 'package:loris/business_logic/interactions/interactions.dart';
|
|
import 'package:loris/business_logic/timeline/timeline.dart';
|
|
import 'package:loris/partials/interaction_button.dart';
|
|
import 'package:url_launcher/url_launcher.dart';
|
|
import 'package:clipboard/clipboard.dart';
|
|
|
|
void popupPostOptions(context, PostModel model) {
|
|
showModalBottomSheet(
|
|
context: context,
|
|
builder: (context) => PostOptions(model: model),
|
|
);
|
|
}
|
|
|
|
class PostOptions extends StatefulWidget {
|
|
const PostOptions({Key? key, required this.model}) : super(key: key);
|
|
final PostModel model;
|
|
|
|
@override
|
|
State<PostOptions> createState() => _PostOptionsState();
|
|
}
|
|
|
|
class _PostOptionsState extends State<PostOptions> {
|
|
bool justCopied = false;
|
|
|
|
@override
|
|
Widget build(BuildContext context) {
|
|
List<Widget?> c = [
|
|
const SizedBox(
|
|
height: 24,
|
|
),
|
|
SelectableText("post-options".i18n(),
|
|
style: Theme.of(context).textTheme.displayMedium),
|
|
SelectableText(
|
|
widget.model.createdAt
|
|
.replaceAll("T", " ")
|
|
.replaceAll("-", ".")
|
|
.substring(0, 19),
|
|
style: Theme.of(context).textTheme.bodyMedium,
|
|
),
|
|
Row(
|
|
mainAxisAlignment: MainAxisAlignment.center,
|
|
children: [
|
|
Icon(widget.model.visibility.icon),
|
|
SelectableText(widget.model.visibility.name),
|
|
],
|
|
),
|
|
const SizedBox(
|
|
height: 24,
|
|
),
|
|
TextButton.icon(
|
|
onPressed: () async {
|
|
FlutterClipboard.copy(widget.model.uri);
|
|
setState(() {
|
|
justCopied = true;
|
|
});
|
|
await Future.delayed(const Duration(seconds: 1));
|
|
if (mounted) {
|
|
setState(() {
|
|
justCopied = false;
|
|
});
|
|
}
|
|
},
|
|
icon: const Icon(Icons.copy),
|
|
label: Text(
|
|
justCopied
|
|
? "${"copied-post-by".i18n()} ${widget.model.account.acct}"
|
|
: "copy-url-to-clipboard".i18n(),
|
|
),
|
|
),
|
|
TextButton.icon(
|
|
onPressed: () {
|
|
launchUrl(
|
|
Uri.parse(widget.model.uri),
|
|
);
|
|
},
|
|
icon: const Icon(Icons.open_in_browser),
|
|
label: Text(
|
|
"show-in-browser".i18n(),
|
|
),
|
|
),
|
|
widget.model.visibility.boostable
|
|
? InteractionButton(
|
|
model: widget.model,
|
|
type: InteractionType.reblog,
|
|
extended: true,
|
|
)
|
|
: null,
|
|
InteractionButton(
|
|
model: widget.model,
|
|
type: InteractionType.favorite,
|
|
extended: true,
|
|
),
|
|
const SizedBox(
|
|
height: 24,
|
|
),
|
|
];
|
|
return SingleChildScrollView(
|
|
child: Column(
|
|
mainAxisAlignment: MainAxisAlignment.center,
|
|
children: [
|
|
for (var i in c)
|
|
if (i != null) i
|
|
],
|
|
),
|
|
);
|
|
}
|
|
}
|