diff --git a/lib/pages/chat/edit_widgets_dialog.dart b/lib/pages/chat/edit_widgets_dialog.dart deleted file mode 100644 index 2ba163fe..00000000 --- a/lib/pages/chat/edit_widgets_dialog.dart +++ /dev/null @@ -1,34 +0,0 @@ -import 'package:flutter/material.dart'; - -import 'package:flutter_gen/gen_l10n/l10n.dart'; -import 'package:matrix/matrix.dart'; - -import 'add_widget_tile.dart'; - -class EditWidgetsDialog extends StatelessWidget { - final Room room; - - const EditWidgetsDialog({super.key, required this.room}); - - @override - Widget build(BuildContext context) { - return SimpleDialog( - title: Text(L10n.of(context)!.editWidgets), - children: [ - ...room.widgets.map( - (e) => ListTile( - title: Text(e.name ?? e.type), - leading: IconButton( - onPressed: () { - room.deleteWidget(e.id!); - Navigator.of(context).pop(); - }, - icon: const Icon(Icons.delete), - ), - ), - ), - AddWidgetTile(room: room), - ], - ); - } -} diff --git a/lib/utils/matrix_sdk_extensions/presence_extension.dart b/lib/utils/matrix_sdk_extensions/presence_extension.dart deleted file mode 100644 index bb6e1069..00000000 --- a/lib/utils/matrix_sdk_extensions/presence_extension.dart +++ /dev/null @@ -1,40 +0,0 @@ -import 'package:flutter/material.dart'; - -import 'package:flutter_gen/gen_l10n/l10n.dart'; -import 'package:matrix/matrix.dart'; - -import '../date_time_extension.dart'; - -extension PresenceExtension on CachedPresence { - String getLocalizedLastActiveAgo(BuildContext context) { - final lastActiveTimestamp = this.lastActiveTimestamp; - if (lastActiveTimestamp != null) { - return L10n.of(context)! - .lastActiveAgo(lastActiveTimestamp.localizedTimeShort(context)); - } - return L10n.of(context)!.lastSeenLongTimeAgo; - } - - String getLocalizedStatusMessage(BuildContext context) { - final statusMsg = this.statusMsg; - if (statusMsg != null && statusMsg.isNotEmpty) { - return statusMsg; - } - if (currentlyActive ?? false) { - return L10n.of(context)!.currentlyActive; - } - return getLocalizedLastActiveAgo(context); - } - - Color get color { - switch (presence) { - case PresenceType.online: - return Colors.green; - case PresenceType.offline: - return Colors.grey; - case PresenceType.unavailable: - default: - return Colors.red; - } - } -} diff --git a/lib/utils/string_extension.dart b/lib/utils/string_extension.dart deleted file mode 100644 index 3c77ed4a..00000000 --- a/lib/utils/string_extension.dart +++ /dev/null @@ -1,15 +0,0 @@ -extension StringCasingExtension on String { - String removeDiacritics() { - const withDia = - 'ÀÁÂÃÄÅàáâãäåÒÓÔÕÕÖØòóôõöøÈÉÊËèéêëðÇçÐÌÍÎÏìíîïÙÚÛÜùúûüÑñŠšŸÿýŽž'; - const withoutDia = - 'AAAAAAaaaaaaOOOOOOOooooooEEEEeeeeeCcDIIIIiiiiUUUUuuuuNnSsYyyZz'; - - String str = this; - for (int i = 0; i < withDia.length; i++) { - str = str.replaceAll(withDia[i], withoutDia[i]); - } - - return str; - } -} diff --git a/lib/utils/update_checker_no_store.dart b/lib/utils/update_checker_no_store.dart deleted file mode 100644 index d41bc07f..00000000 --- a/lib/utils/update_checker_no_store.dart +++ /dev/null @@ -1,117 +0,0 @@ -import 'dart:convert'; -import 'dart:io'; - -import 'package:flutter/foundation.dart'; -import 'package:flutter/material.dart'; - -import 'package:adaptive_dialog/adaptive_dialog.dart'; -import 'package:flutter_gen/gen_l10n/l10n.dart'; -import 'package:http/http.dart'; -import 'package:matrix/matrix.dart'; -import 'package:path_provider/path_provider.dart'; - -import 'platform_infos.dart'; - -/// helper class checking for updates on platforms without store release -/// -/// Currently, this is only Windows -class UpdateCheckerNoStore { - static const gitLabProjectId = '16112282'; - static const gitLabHost = 'gitlab.com'; - - static Uri get tagsUri => Uri.parse( - 'https://$gitLabHost/projects/$gitLabProjectId/repository/tags', - ); - - final BuildContext context; - - const UpdateCheckerNoStore(this.context); - - Future checkUpdate() async { - // platform-specific implementations - try { - if (PlatformInfos.isWindows) { - final response = await get(tagsUri); - if (response.statusCode == 200) { - final json = jsonDecode(response.body); - var latestTag = json[0]['name'] as String; - var currentVersion = await PlatformInfos.getVersion(); - - if (latestTag.startsWith('v')) { - latestTag = latestTag.substring(1); - } - if (currentVersion.startsWith('v')) { - currentVersion = currentVersion.substring(1); - } - if (latestTag != currentVersion) { - final metadata = UpdateMetadata(latestTag); - await showUpdateDialog(metadata); - } - return; - } else { - throw response; - } - } else { - return; - } - } catch (e) { - Logs().i('Could not look for updates:', e); - return; - } - } - - Uri downloadUri(UpdateMetadata metadata) { - // platform specific - if (PlatformInfos.isWindows) { - return Uri.parse('https://$gitLabHost/famedly/fluffychat/-' - '/jobs/artifacts/$metadata/raw/' - 'build/windows/runner/Release/fluffychat.msix?job=build_windows'); - } else { - throw UnimplementedError('No download URI available for this platform.'); - } - } - - /// launches an app update - /// - /// Either uses the operating systems package or app management to perform - /// an update or launches a custom installer - Future launchUpdater(UpdateMetadata metadata) async { - // platform specific - try { - if (kIsWeb) return; - if (PlatformInfos.isWindows) { - final dir = await getTemporaryDirectory(); - final response = await get(downloadUri(metadata)); - if (response.statusCode == 200) { - final file = File('${dir.path}/fluffychat.msix'); - await file.writeAsBytes(response.bodyBytes); - Process.start(file.path, [], runInShell: true); - } else { - throw response; - } - } - } catch (e) { - Logs().w('Error launching th update:', e); - } - } - - Future showUpdateDialog(UpdateMetadata metadata) async { - final result = await showOkCancelAlertDialog( - title: L10n.of(context)!.updateAvailable, - message: L10n.of(context)!.updateNow, - context: context, - ); - if (result == OkCancelResult.ok) { - await launchUpdater(metadata); - } - } -} - -class UpdateMetadata { - final String version; - - const UpdateMetadata(this.version); - - @override - String toString() => 'v$version'; -} diff --git a/lib/widgets/adaptive_flat_button.dart b/lib/widgets/adaptive_flat_button.dart deleted file mode 100644 index faed7e95..00000000 --- a/lib/widgets/adaptive_flat_button.dart +++ /dev/null @@ -1,35 +0,0 @@ -import 'package:flutter/cupertino.dart'; -import 'package:flutter/material.dart'; - -import 'package:fluffychat/utils/platform_infos.dart'; - -class AdaptiveFlatButton extends StatelessWidget { - final String label; - final Color? textColor; - final void Function()? onPressed; - - const AdaptiveFlatButton({ - super.key, - required this.label, - this.textColor, - this.onPressed, - }); - - @override - Widget build(BuildContext context) { - if (PlatformInfos.isCupertinoStyle) { - return CupertinoDialogAction( - onPressed: onPressed, - textStyle: textColor != null ? TextStyle(color: textColor) : null, - child: Text(label), - ); - } - return TextButton( - onPressed: onPressed, - child: Text( - label, - style: TextStyle(color: textColor), - ), - ); - } -} diff --git a/lib/widgets/content_banner.dart b/lib/widgets/content_banner.dart deleted file mode 100644 index f9e6a616..00000000 --- a/lib/widgets/content_banner.dart +++ /dev/null @@ -1,82 +0,0 @@ -import 'package:flutter/material.dart'; - -import 'package:matrix/matrix.dart'; - -import 'package:fluffychat/widgets/mxc_image.dart'; - -class ContentBanner extends StatelessWidget { - final Uri? mxContent; - final double height; - final IconData defaultIcon; - final void Function()? onEdit; - final Client? client; - final double opacity; - final WidgetBuilder? placeholder; - - const ContentBanner({ - this.mxContent, - this.height = 400, - this.defaultIcon = Icons.account_circle_outlined, - this.onEdit, - this.client, - this.opacity = 0.75, - this.placeholder, - super.key, - }); - - @override - Widget build(BuildContext context) { - final onEdit = this.onEdit; - return Container( - height: height, - alignment: Alignment.center, - decoration: BoxDecoration( - color: Theme.of(context).colorScheme.secondaryContainer, - ), - child: Stack( - children: [ - Positioned( - left: 0, - right: 0, - top: 0, - bottom: 0, - child: Opacity( - opacity: opacity, - child: mxContent == null - ? Center( - child: Icon( - defaultIcon, - color: - Theme.of(context).colorScheme.onSecondaryContainer, - size: 128, - ), - ) - : MxcImage( - key: Key(mxContent?.toString() ?? 'NoKey'), - uri: mxContent, - animated: true, - fit: BoxFit.cover, - placeholder: placeholder, - height: 400, - width: 800, - ), - ), - ), - if (onEdit != null) - Container( - margin: const EdgeInsets.all(8), - alignment: Alignment.bottomRight, - child: FloatingActionButton( - mini: true, - heroTag: null, - onPressed: onEdit, - backgroundColor: Theme.of(context).colorScheme.background, - foregroundColor: Theme.of(context).textTheme.bodyLarge?.color, - child: const Icon(Icons.camera_alt_outlined), - ), - ), - ], - ), - ); - } -}