2022-02-02 14:31:15 +01:00
|
|
|
import 'package:flutter/cupertino.dart';
|
|
|
|
|
|
|
|
import 'package:flutter_gen/gen_l10n/l10n.dart';
|
|
|
|
import 'package:matrix/matrix.dart';
|
|
|
|
import 'package:url_launcher/link.dart';
|
|
|
|
|
2022-03-23 14:09:35 +01:00
|
|
|
import 'edit_widgets_dialog.dart';
|
|
|
|
|
2022-02-02 14:31:15 +01:00
|
|
|
class CupertinoWidgetsBottomSheet extends StatelessWidget {
|
|
|
|
final Room room;
|
|
|
|
|
|
|
|
const CupertinoWidgetsBottomSheet({Key? key, required this.room})
|
|
|
|
: super(key: key);
|
2022-03-23 14:09:35 +01:00
|
|
|
|
2022-02-02 14:31:15 +01:00
|
|
|
@override
|
|
|
|
Widget build(BuildContext context) {
|
|
|
|
return CupertinoActionSheet(
|
|
|
|
title: Text(L10n.of(context)!.matrixWidgets),
|
|
|
|
actions: [
|
|
|
|
...room.widgets.map(
|
|
|
|
(widget) => Link(
|
|
|
|
builder: (context, callback) {
|
|
|
|
return CupertinoActionSheetAction(
|
|
|
|
onPressed: callback ?? () {},
|
2022-08-14 16:59:21 +02:00
|
|
|
child: Text(widget.name ?? widget.url),
|
2022-02-02 14:31:15 +01:00
|
|
|
);
|
|
|
|
},
|
|
|
|
target: LinkTarget.blank,
|
|
|
|
uri: Uri.parse(widget.url),
|
|
|
|
),
|
|
|
|
),
|
|
|
|
CupertinoActionSheetAction(
|
2022-03-23 14:09:35 +01:00
|
|
|
child: Text(L10n.of(context)!.editWidgets),
|
|
|
|
onPressed: () {
|
|
|
|
Navigator.of(context).pop();
|
|
|
|
showCupertinoDialog(
|
|
|
|
context: context,
|
|
|
|
builder: (context) => EditWidgetsDialog(room: room),
|
2022-04-03 12:59:08 +02:00
|
|
|
useRootNavigator: false,
|
2022-03-23 14:09:35 +01:00
|
|
|
);
|
|
|
|
},
|
2022-02-02 14:31:15 +01:00
|
|
|
),
|
|
|
|
CupertinoActionSheetAction(
|
|
|
|
onPressed: Navigator.of(context).pop,
|
2022-08-14 16:59:21 +02:00
|
|
|
child: Text(L10n.of(context)!.cancel),
|
2022-02-02 14:31:15 +01:00
|
|
|
),
|
|
|
|
],
|
|
|
|
);
|
|
|
|
}
|
|
|
|
}
|