mirror of
https://github.com/krille-chan/fluffychat
synced 2024-09-17 09:35:12 +00:00
change: Remove widgets feature
This commit is contained in:
parent
8ed54497f9
commit
83d5d3ec58
3 changed files with 0 additions and 145 deletions
|
@ -1,50 +0,0 @@
|
|||
import 'package:flutter/cupertino.dart';
|
||||
|
||||
import 'package:flutter_gen/gen_l10n/l10n.dart';
|
||||
import 'package:matrix/matrix.dart';
|
||||
import 'package:url_launcher/link.dart';
|
||||
|
||||
import 'edit_widgets_dialog.dart';
|
||||
|
||||
class CupertinoWidgetsBottomSheet extends StatelessWidget {
|
||||
final Room room;
|
||||
|
||||
const CupertinoWidgetsBottomSheet({Key? key, required this.room})
|
||||
: super(key: key);
|
||||
|
||||
@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 ?? () {},
|
||||
child: Text(widget.name ?? widget.url),
|
||||
);
|
||||
},
|
||||
target: LinkTarget.blank,
|
||||
uri: Uri.parse(widget.url),
|
||||
),
|
||||
),
|
||||
CupertinoActionSheetAction(
|
||||
child: Text(L10n.of(context)!.editWidgets),
|
||||
onPressed: () {
|
||||
Navigator.of(context).pop();
|
||||
showCupertinoDialog(
|
||||
context: context,
|
||||
builder: (context) => EditWidgetsDialog(room: room),
|
||||
useRootNavigator: false,
|
||||
);
|
||||
},
|
||||
),
|
||||
CupertinoActionSheetAction(
|
||||
onPressed: Navigator.of(context).pop,
|
||||
child: Text(L10n.of(context)!.cancel),
|
||||
),
|
||||
],
|
||||
);
|
||||
}
|
||||
}
|
|
@ -1,49 +0,0 @@
|
|||
import 'package:flutter/material.dart';
|
||||
|
||||
import 'package:flutter_gen/gen_l10n/l10n.dart';
|
||||
import 'package:matrix/matrix.dart';
|
||||
import 'package:url_launcher/link.dart';
|
||||
|
||||
import 'edit_widgets_dialog.dart';
|
||||
|
||||
class WidgetsBottomSheet extends StatelessWidget {
|
||||
final Room room;
|
||||
|
||||
const WidgetsBottomSheet({Key? key, required this.room}) : super(key: key);
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
return ListView.builder(
|
||||
shrinkWrap: true,
|
||||
itemBuilder: (context, index) {
|
||||
if (index == room.widgets.length) {
|
||||
return ListTile(
|
||||
leading: const Icon(Icons.edit),
|
||||
title: Text(L10n.of(context)!.editWidgets),
|
||||
onTap: () {
|
||||
Navigator.of(context).pop();
|
||||
showDialog(
|
||||
context: context,
|
||||
builder: (context) => EditWidgetsDialog(room: room),
|
||||
useRootNavigator: false,
|
||||
);
|
||||
},
|
||||
);
|
||||
}
|
||||
final widget = room.widgets[index];
|
||||
return Link(
|
||||
builder: (context, callback) {
|
||||
return ListTile(
|
||||
title: Text(widget.name ?? widget.url),
|
||||
subtitle: Text(widget.type),
|
||||
onTap: callback,
|
||||
);
|
||||
},
|
||||
target: LinkTarget.blank,
|
||||
uri: Uri.parse(widget.url),
|
||||
);
|
||||
},
|
||||
itemCount: room.widgets.length + 1,
|
||||
);
|
||||
}
|
||||
}
|
|
@ -1,6 +1,5 @@
|
|||
import 'dart:async';
|
||||
|
||||
import 'package:flutter/cupertino.dart';
|
||||
import 'package:flutter/material.dart';
|
||||
import 'package:flutter/services.dart';
|
||||
|
||||
|
@ -11,10 +10,6 @@ import 'package:go_router/go_router.dart';
|
|||
import 'package:keyboard_shortcuts/keyboard_shortcuts.dart';
|
||||
import 'package:matrix/matrix.dart';
|
||||
|
||||
import 'package:fluffychat/pages/chat/cupertino_widgets_bottom_sheet.dart';
|
||||
import 'package:fluffychat/pages/chat/edit_widgets_dialog.dart';
|
||||
import 'package:fluffychat/pages/chat/widgets_bottom_sheet.dart';
|
||||
import 'package:fluffychat/utils/adaptive_bottom_sheet.dart';
|
||||
import 'matrix.dart';
|
||||
|
||||
class ChatSettingsPopupMenu extends StatefulWidget {
|
||||
|
@ -48,16 +43,6 @@ class ChatSettingsPopupMenuState extends State<ChatSettingsPopupMenu> {
|
|||
(u) => setState(() {}),
|
||||
);
|
||||
final items = <PopupMenuEntry<String>>[
|
||||
PopupMenuItem<String>(
|
||||
value: 'widgets',
|
||||
child: Row(
|
||||
children: [
|
||||
const Icon(Icons.widgets_outlined),
|
||||
const SizedBox(width: 12),
|
||||
Text(L10n.of(context)!.matrixWidgets),
|
||||
],
|
||||
),
|
||||
),
|
||||
widget.room.pushRuleState == PushRuleState.notify
|
||||
? PopupMenuItem<String>(
|
||||
value: 'mute',
|
||||
|
@ -117,29 +102,9 @@ class ChatSettingsPopupMenuState extends State<ChatSettingsPopupMenu> {
|
|||
onKeysPressed: _showChatDetails,
|
||||
child: const SizedBox.shrink(),
|
||||
),
|
||||
KeyBoardShortcuts(
|
||||
keysToPress: {
|
||||
LogicalKeyboardKey.controlLeft,
|
||||
LogicalKeyboardKey.keyW
|
||||
},
|
||||
helpLabel: L10n.of(context)!.matrixWidgets,
|
||||
onKeysPressed: _showWidgets,
|
||||
child: const SizedBox.shrink(),
|
||||
),
|
||||
PopupMenuButton(
|
||||
onSelected: (String choice) async {
|
||||
switch (choice) {
|
||||
case 'widgets':
|
||||
if (widget.room.widgets.isNotEmpty) {
|
||||
_showWidgets();
|
||||
} else {
|
||||
showDialog(
|
||||
context: context,
|
||||
builder: (context) => EditWidgetsDialog(room: widget.room),
|
||||
useRootNavigator: false,
|
||||
);
|
||||
}
|
||||
break;
|
||||
case 'leave':
|
||||
final confirmed = await showOkCancelAlertDialog(
|
||||
useRootNavigator: false,
|
||||
|
@ -183,17 +148,6 @@ class ChatSettingsPopupMenuState extends State<ChatSettingsPopupMenu> {
|
|||
);
|
||||
}
|
||||
|
||||
void _showWidgets() => [TargetPlatform.iOS, TargetPlatform.macOS]
|
||||
.contains(Theme.of(context).platform)
|
||||
? showCupertinoModalPopup(
|
||||
context: context,
|
||||
builder: (context) => CupertinoWidgetsBottomSheet(room: widget.room),
|
||||
)
|
||||
: showAdaptiveBottomSheet(
|
||||
context: context,
|
||||
builder: (context) => WidgetsBottomSheet(room: widget.room),
|
||||
);
|
||||
|
||||
void _showChatDetails() {
|
||||
if (GoRouterState.of(context).uri.path.endsWith('/details')) {
|
||||
context.go('/rooms/${widget.room.id}');
|
||||
|
|
Loading…
Reference in a new issue