mirror of
https://github.com/krille-chan/fluffychat
synced 2024-09-10 13:05:11 +00:00
refactor: Remove unused code
This commit is contained in:
parent
4a6a77336c
commit
1f7ce96623
6 changed files with 0 additions and 323 deletions
|
@ -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),
|
||||
],
|
||||
);
|
||||
}
|
||||
}
|
|
@ -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;
|
||||
}
|
||||
}
|
||||
}
|
|
@ -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;
|
||||
}
|
||||
}
|
|
@ -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<void> 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<void> 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<void> 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';
|
||||
}
|
|
@ -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),
|
||||
),
|
||||
);
|
||||
}
|
||||
}
|
|
@ -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: <Widget>[
|
||||
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),
|
||||
),
|
||||
),
|
||||
],
|
||||
),
|
||||
);
|
||||
}
|
||||
}
|
Loading…
Reference in a new issue