.github
android
api
assets
ios
lib
controllers
providers
screens
types
widgets
account
attachment
attachment_input.dart
attachment_item.dart
attachment_list.dart
attachment_zoom.dart
pending_attachment_alt.dart
pending_attachment_boost.dart
pending_attachment_compress.dart
chat
navigation
post
about.dart
app_bar_leading.dart
connection_indicator.dart
context_menu.dart
dialog.dart
link_preview.dart
loading_indicator.dart
markdown_content.dart
unauthorized_hint.dart
universal_image.dart
version_label.dart
firebase_options.dart
main.dart
router.dart
theme.dart
linux
macos
snap
web
windows
.gitignore
.metadata
.roadsignrc
analysis_options.yaml
build.yaml
devtools_options.yaml
firebase.json
pubspec.lock
pubspec.yaml
roadsign.toml
87 lines
2.4 KiB
Dart
87 lines
2.4 KiB
Dart
import 'package:easy_localization/easy_localization.dart';
|
|
import 'package:flutter/material.dart';
|
|
import 'package:provider/provider.dart';
|
|
import 'package:surface/controllers/post_write_controller.dart';
|
|
import 'package:surface/providers/sn_attachment.dart';
|
|
import 'package:surface/widgets/dialog.dart';
|
|
|
|
class PendingAttachmentAltDialog extends StatefulWidget {
|
|
final PostWriteMedia media;
|
|
const PendingAttachmentAltDialog({super.key, required this.media});
|
|
|
|
@override
|
|
State<PendingAttachmentAltDialog> createState() => _PendingAttachmentAltDialogState();
|
|
}
|
|
|
|
class _PendingAttachmentAltDialogState extends State<PendingAttachmentAltDialog> {
|
|
final _contentController = TextEditingController();
|
|
|
|
@override
|
|
void initState() {
|
|
super.initState();
|
|
_contentController.text = widget.media.attachment!.alt;
|
|
}
|
|
|
|
bool _isBusy = false;
|
|
|
|
Future<void> _performAction() async {
|
|
if (_isBusy) return;
|
|
|
|
setState(() => _isBusy = true);
|
|
|
|
try {
|
|
final attach = context.read<SnAttachmentProvider>();
|
|
final result = await attach.updateOne(
|
|
widget.media.attachment!,
|
|
alt: _contentController.text,
|
|
);
|
|
if (!mounted) return;
|
|
attach.putCache([result]);
|
|
Navigator.pop(context, result);
|
|
} catch (err) {
|
|
if (!mounted) return;
|
|
context.showErrorDialog(err);
|
|
setState(() => _isBusy = false);
|
|
}
|
|
}
|
|
|
|
@override
|
|
void dispose() {
|
|
_contentController.dispose();
|
|
super.dispose();
|
|
}
|
|
|
|
@override
|
|
Widget build(BuildContext context) {
|
|
return AlertDialog(
|
|
title: Text('attachmentSetAlt').tr(),
|
|
content: Column(
|
|
mainAxisSize: MainAxisSize.min,
|
|
crossAxisAlignment: CrossAxisAlignment.start,
|
|
children: [
|
|
TextField(
|
|
controller: _contentController,
|
|
decoration: InputDecoration(
|
|
labelText: 'fieldAttachmentAlt'.tr(),
|
|
border: const UnderlineInputBorder(),
|
|
),
|
|
onTapOutside: (_) => FocusManager.instance.primaryFocus?.unfocus(),
|
|
),
|
|
],
|
|
),
|
|
actions: [
|
|
TextButton(
|
|
onPressed: _isBusy ? null : () {
|
|
Navigator.pop(context);
|
|
},
|
|
child: Text('dialogDismiss'.tr()),
|
|
),
|
|
TextButton(
|
|
onPressed: _isBusy ? null : () => _performAction(),
|
|
child: Text('dialogConfirm'.tr()),
|
|
),
|
|
],
|
|
);
|
|
}
|
|
}
|