- Canais: publicações viram cartões de largura total mantendo todas as funções do balão (reações, resposta, editar, excluir, comentários em thread). Composer de publicação fica restrito a admins no feed; membros comentam via tela de thread. Canais novos usam events_default 0 para permitir comentários e reações. - Ao sair/excluir uma sala, a cópia local é removida do banco imediatamente; salas já deixadas no servidor não apresentam mais erro ao excluir de novo. - Classificação mural/canal carregada direto do sync (room_type em importantStateEvents + postLoad) sem precisar abrir a sala. - Diálogos com raio e padding reduzidos (dialogTheme, text input e ok/cancel). - Ícones do app regenerados (logo_background) e dependência linkify.
111 lines
3.7 KiB
Dart
111 lines
3.7 KiB
Dart
// SPDX-FileCopyrightText: 2019-Present Christian Kußowski
|
|
// SPDX-FileCopyrightText: 2019-Present Contributors to FluffyChat
|
|
//
|
|
// SPDX-License-Identifier: AGPL-3.0-or-later
|
|
|
|
import 'package:tatchat/l10n/l10n.dart';
|
|
import 'package:tatchat/utils/url_launcher.dart';
|
|
import 'package:tatchat/widgets/adaptive_dialogs/adaptive_dialog_action.dart';
|
|
import 'package:flutter_linkify/flutter_linkify.dart';
|
|
import 'package:material_ui/material_ui.dart';
|
|
|
|
enum OkCancelResult { ok, cancel }
|
|
|
|
Future<OkCancelResult?> showOkCancelAlertDialog({
|
|
required BuildContext context,
|
|
required String title,
|
|
String? message,
|
|
String? okLabel,
|
|
String? cancelLabel,
|
|
bool isDestructive = false,
|
|
bool useRootNavigator = true,
|
|
}) => showAdaptiveDialog<OkCancelResult>(
|
|
context: context,
|
|
useRootNavigator: useRootNavigator,
|
|
builder: (context) => AlertDialog.adaptive(
|
|
title: ConstrainedBox(
|
|
constraints: const BoxConstraints(maxWidth: 256),
|
|
child: Text(title),
|
|
),
|
|
titlePadding: const EdgeInsets.fromLTRB(20, 16, 20, 0),
|
|
contentPadding: const EdgeInsets.fromLTRB(20, 12, 20, 20),
|
|
content: ConstrainedBox(
|
|
constraints: const BoxConstraints(maxWidth: 256),
|
|
child: message == null
|
|
? null
|
|
: SelectableLinkify(
|
|
text: message,
|
|
textScaleFactor: MediaQuery.textScalerOf(context).scale(1),
|
|
linkStyle: TextStyle(
|
|
color: Theme.of(context).colorScheme.primary,
|
|
decorationColor: Theme.of(context).colorScheme.primary,
|
|
),
|
|
options: const LinkifyOptions(humanize: false),
|
|
onOpen: (url) => UrlLauncher(context, url.url).launchUrl(),
|
|
),
|
|
),
|
|
actions: [
|
|
AdaptiveDialogAction(
|
|
key: Key('ok_cancel_alert_dialog_cancel_button'),
|
|
onPressed: () =>
|
|
Navigator.of(context).pop<OkCancelResult>(OkCancelResult.cancel),
|
|
child: Text(cancelLabel ?? L10n.of(context).cancel),
|
|
),
|
|
AdaptiveDialogAction(
|
|
key: Key('ok_cancel_alert_dialog_ok_button'),
|
|
onPressed: () =>
|
|
Navigator.of(context).pop<OkCancelResult>(OkCancelResult.ok),
|
|
autofocus: true,
|
|
child: Text(
|
|
okLabel ?? L10n.of(context).ok,
|
|
style: isDestructive
|
|
? TextStyle(color: Theme.of(context).colorScheme.error)
|
|
: null,
|
|
),
|
|
),
|
|
],
|
|
),
|
|
);
|
|
|
|
Future<OkCancelResult?> showOkAlertDialog({
|
|
required BuildContext context,
|
|
required String title,
|
|
String? message,
|
|
String? okLabel,
|
|
bool useRootNavigator = true,
|
|
}) => showAdaptiveDialog<OkCancelResult>(
|
|
context: context,
|
|
useRootNavigator: useRootNavigator,
|
|
builder: (context) => AlertDialog.adaptive(
|
|
title: ConstrainedBox(
|
|
constraints: const BoxConstraints(maxWidth: 256),
|
|
child: Text(title),
|
|
),
|
|
titlePadding: const EdgeInsets.fromLTRB(20, 16, 20, 0),
|
|
contentPadding: const EdgeInsets.fromLTRB(20, 12, 20, 20),
|
|
content: ConstrainedBox(
|
|
constraints: const BoxConstraints(maxWidth: 256),
|
|
child: message == null
|
|
? null
|
|
: SelectableLinkify(
|
|
text: message,
|
|
textScaleFactor: MediaQuery.textScalerOf(context).scale(1),
|
|
linkStyle: TextStyle(
|
|
color: Theme.of(context).colorScheme.primary,
|
|
decorationColor: Theme.of(context).colorScheme.primary,
|
|
),
|
|
options: const LinkifyOptions(humanize: false),
|
|
onOpen: (url) => UrlLauncher(context, url.url).launchUrl(),
|
|
),
|
|
),
|
|
actions: [
|
|
AdaptiveDialogAction(
|
|
onPressed: () =>
|
|
Navigator.of(context).pop<OkCancelResult>(OkCancelResult.ok),
|
|
autofocus: true,
|
|
child: Text(okLabel ?? L10n.of(context).close),
|
|
),
|
|
],
|
|
),
|
|
);
|