dart format
This commit is contained in:
@@ -1,4 +1,3 @@
|
||||
|
||||
import 'package:flutter/material.dart';
|
||||
|
||||
class About extends StatelessWidget {
|
||||
@@ -6,13 +5,11 @@ class About extends StatelessWidget {
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context) => Scaffold(
|
||||
appBar: AppBar(
|
||||
title: const Text('Über diese App'),
|
||||
),
|
||||
body: const Card(
|
||||
elevation: 1,
|
||||
borderOnForeground: true,
|
||||
child: Text('Marianum Fulda'),
|
||||
),
|
||||
);
|
||||
appBar: AppBar(title: const Text('Über diese App')),
|
||||
body: const Card(
|
||||
elevation: 1,
|
||||
borderOnForeground: true,
|
||||
child: Text('Marianum Fulda'),
|
||||
),
|
||||
);
|
||||
}
|
||||
|
||||
@@ -29,30 +29,43 @@ class _AnimatedTimeState extends State<AnimatedTime> {
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context) => Row(
|
||||
children: [
|
||||
const Text('Noch '),
|
||||
buildWidget(current.inDays),
|
||||
const Text(' Tage, '),
|
||||
buildWidget(current.inHours > 24 ? current.inHours - current.inDays * 24 : current.inHours),
|
||||
const Text(':'),
|
||||
buildWidget(current.inMinutes > 60 ? current.inMinutes - current.inHours * 60 : current.inMinutes),
|
||||
const Text(':'),
|
||||
buildWidget(current.inSeconds > 60 ? current.inSeconds - current.inMinutes * 60 : current.inSeconds),
|
||||
],
|
||||
);
|
||||
children: [
|
||||
const Text('Noch '),
|
||||
buildWidget(current.inDays),
|
||||
const Text(' Tage, '),
|
||||
buildWidget(
|
||||
current.inHours > 24
|
||||
? current.inHours - current.inDays * 24
|
||||
: current.inHours,
|
||||
),
|
||||
const Text(':'),
|
||||
buildWidget(
|
||||
current.inMinutes > 60
|
||||
? current.inMinutes - current.inHours * 60
|
||||
: current.inMinutes,
|
||||
),
|
||||
const Text(':'),
|
||||
buildWidget(
|
||||
current.inSeconds > 60
|
||||
? current.inSeconds - current.inMinutes * 60
|
||||
: current.inSeconds,
|
||||
),
|
||||
],
|
||||
);
|
||||
|
||||
Widget buildWidget(int value) => AnimatedSwitcher(
|
||||
duration: const Duration(milliseconds: 100),
|
||||
transitionBuilder: (child, animation) => FadeTransition(opacity: animation, child: child),
|
||||
child: Text(
|
||||
'$value',
|
||||
key: ValueKey<int>(value),
|
||||
style: TextStyle(
|
||||
fontSize: 15,
|
||||
color: Theme.of(context).colorScheme.onSurface,
|
||||
),
|
||||
),
|
||||
);
|
||||
duration: const Duration(milliseconds: 100),
|
||||
transitionBuilder: (child, animation) =>
|
||||
FadeTransition(opacity: animation, child: child),
|
||||
child: Text(
|
||||
'$value',
|
||||
key: ValueKey<int>(value),
|
||||
style: TextStyle(
|
||||
fontSize: 15,
|
||||
color: Theme.of(context).colorScheme.onSurface,
|
||||
),
|
||||
),
|
||||
);
|
||||
|
||||
@override
|
||||
void dispose() {
|
||||
|
||||
@@ -12,13 +12,13 @@ class AppProgressIndicator extends StatelessWidget {
|
||||
});
|
||||
|
||||
const AppProgressIndicator.small({Color? color})
|
||||
: this._(size: 16, strokeWidth: 2, color: color);
|
||||
: this._(size: 16, strokeWidth: 2, color: color);
|
||||
|
||||
const AppProgressIndicator.medium({Color? color})
|
||||
: this._(size: 24, strokeWidth: 2.5, color: color);
|
||||
: this._(size: 24, strokeWidth: 2.5, color: color);
|
||||
|
||||
const AppProgressIndicator.large({Color? color})
|
||||
: this._(size: 40, strokeWidth: 3, color: color);
|
||||
: this._(size: 40, strokeWidth: 3, color: color);
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
|
||||
@@ -26,33 +26,33 @@ class AsyncActionButton extends StatelessWidget {
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context) => _AsyncMixin(
|
||||
onPressed: onPressed,
|
||||
controller: controller,
|
||||
errorBuilder: errorBuilder,
|
||||
onError: onError,
|
||||
onSuccess: onSuccess,
|
||||
builder: (context, busy, handler) {
|
||||
final spinner = AppProgressIndicator.small(
|
||||
color: Theme.of(context).colorScheme.onPrimary,
|
||||
);
|
||||
final content = busy
|
||||
? Row(
|
||||
mainAxisSize: MainAxisSize.min,
|
||||
children: [spinner, const SizedBox(width: 8), child],
|
||||
)
|
||||
: (icon != null
|
||||
? Row(
|
||||
mainAxisSize: MainAxisSize.min,
|
||||
children: [Icon(icon), const SizedBox(width: 8), child],
|
||||
)
|
||||
: child);
|
||||
final button = ElevatedButton(
|
||||
onPressed: handler,
|
||||
style: style,
|
||||
child: content,
|
||||
);
|
||||
if (!showInlineError) return button;
|
||||
return _InlineErrorWrapper(controller: controller, child: button);
|
||||
},
|
||||
onPressed: onPressed,
|
||||
controller: controller,
|
||||
errorBuilder: errorBuilder,
|
||||
onError: onError,
|
||||
onSuccess: onSuccess,
|
||||
builder: (context, busy, handler) {
|
||||
final spinner = AppProgressIndicator.small(
|
||||
color: Theme.of(context).colorScheme.onPrimary,
|
||||
);
|
||||
final content = busy
|
||||
? Row(
|
||||
mainAxisSize: MainAxisSize.min,
|
||||
children: [spinner, const SizedBox(width: 8), child],
|
||||
)
|
||||
: (icon != null
|
||||
? Row(
|
||||
mainAxisSize: MainAxisSize.min,
|
||||
children: [Icon(icon), const SizedBox(width: 8), child],
|
||||
)
|
||||
: child);
|
||||
final button = ElevatedButton(
|
||||
onPressed: handler,
|
||||
style: style,
|
||||
child: content,
|
||||
);
|
||||
if (!showInlineError) return button;
|
||||
return _InlineErrorWrapper(controller: controller, child: button);
|
||||
},
|
||||
);
|
||||
}
|
||||
|
||||
@@ -16,9 +16,13 @@ Future<bool> runWithErrorDialog(
|
||||
return true;
|
||||
} catch (e) {
|
||||
if (!context.mounted) return false;
|
||||
final message = errorBuilder != null ? errorBuilder(e) : errorToUserMessage(e);
|
||||
final message = errorBuilder != null
|
||||
? errorBuilder(e)
|
||||
: errorToUserMessage(e);
|
||||
final details = errorToTechnicalDetails(e);
|
||||
final body = details != null && details != message ? '$message\n\n$details' : message;
|
||||
final body = details != null && details != message
|
||||
? '$message\n\n$details'
|
||||
: message;
|
||||
InfoDialog.show(context, body, copyable: true, title: 'Fehler');
|
||||
return false;
|
||||
}
|
||||
|
||||
@@ -31,60 +31,65 @@ class _AsyncDialogActionState extends State<AsyncDialogAction> {
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context) => AnimatedBuilder(
|
||||
animation: _controller,
|
||||
builder: (context, _) {
|
||||
final err = _controller.error;
|
||||
return Column(
|
||||
mainAxisSize: MainAxisSize.min,
|
||||
crossAxisAlignment: CrossAxisAlignment.stretch,
|
||||
children: [
|
||||
if (err != null)
|
||||
Padding(
|
||||
padding: const EdgeInsets.only(bottom: 8),
|
||||
child: Text(
|
||||
err,
|
||||
textAlign: TextAlign.center,
|
||||
style: TextStyle(color: Theme.of(context).colorScheme.error, fontSize: 13),
|
||||
),
|
||||
animation: _controller,
|
||||
builder: (context, _) {
|
||||
final err = _controller.error;
|
||||
return Column(
|
||||
mainAxisSize: MainAxisSize.min,
|
||||
crossAxisAlignment: CrossAxisAlignment.stretch,
|
||||
children: [
|
||||
if (err != null)
|
||||
Padding(
|
||||
padding: const EdgeInsets.only(bottom: 8),
|
||||
child: Text(
|
||||
err,
|
||||
textAlign: TextAlign.center,
|
||||
style: TextStyle(
|
||||
color: Theme.of(context).colorScheme.error,
|
||||
fontSize: 13,
|
||||
),
|
||||
Row(
|
||||
mainAxisAlignment: MainAxisAlignment.end,
|
||||
children: [
|
||||
if (widget.cancelLabel != null)
|
||||
TextButton(
|
||||
onPressed: _controller.busy ? null : () => Navigator.of(context).pop(),
|
||||
child: Text(widget.cancelLabel!),
|
||||
),
|
||||
TextButton(
|
||||
style: widget.confirmStyle,
|
||||
onPressed: _controller.busy
|
||||
? null
|
||||
: () async {
|
||||
final ok = await _controller.run(
|
||||
widget.onConfirm,
|
||||
errorBuilder: widget.errorBuilder,
|
||||
);
|
||||
if (ok && context.mounted) {
|
||||
Navigator.of(context).pop(true);
|
||||
}
|
||||
},
|
||||
child: _controller.busy
|
||||
? Row(
|
||||
mainAxisSize: MainAxisSize.min,
|
||||
children: [
|
||||
AppProgressIndicator.small(
|
||||
color: Theme.of(context).colorScheme.primary,
|
||||
),
|
||||
const SizedBox(width: 8),
|
||||
Text(widget.confirmLabel),
|
||||
],
|
||||
)
|
||||
: Text(widget.confirmLabel),
|
||||
),
|
||||
],
|
||||
),
|
||||
),
|
||||
Row(
|
||||
mainAxisAlignment: MainAxisAlignment.end,
|
||||
children: [
|
||||
if (widget.cancelLabel != null)
|
||||
TextButton(
|
||||
onPressed: _controller.busy
|
||||
? null
|
||||
: () => Navigator.of(context).pop(),
|
||||
child: Text(widget.cancelLabel!),
|
||||
),
|
||||
TextButton(
|
||||
style: widget.confirmStyle,
|
||||
onPressed: _controller.busy
|
||||
? null
|
||||
: () async {
|
||||
final ok = await _controller.run(
|
||||
widget.onConfirm,
|
||||
errorBuilder: widget.errorBuilder,
|
||||
);
|
||||
if (ok && context.mounted) {
|
||||
Navigator.of(context).pop(true);
|
||||
}
|
||||
},
|
||||
child: _controller.busy
|
||||
? Row(
|
||||
mainAxisSize: MainAxisSize.min,
|
||||
children: [
|
||||
AppProgressIndicator.small(
|
||||
color: Theme.of(context).colorScheme.primary,
|
||||
),
|
||||
const SizedBox(width: 8),
|
||||
Text(widget.confirmLabel),
|
||||
],
|
||||
)
|
||||
: Text(widget.confirmLabel),
|
||||
),
|
||||
],
|
||||
);
|
||||
},
|
||||
),
|
||||
],
|
||||
);
|
||||
},
|
||||
);
|
||||
}
|
||||
|
||||
@@ -28,21 +28,21 @@ class AsyncFab extends StatelessWidget {
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context) => _AsyncMixin(
|
||||
onPressed: onPressed,
|
||||
controller: controller,
|
||||
errorBuilder: errorBuilder,
|
||||
onError: onError,
|
||||
onSuccess: onSuccess,
|
||||
builder: (context, busy, handler) {
|
||||
final fg = foregroundColor ?? Theme.of(context).colorScheme.onPrimary;
|
||||
return FloatingActionButton(
|
||||
heroTag: heroTag,
|
||||
backgroundColor: backgroundColor,
|
||||
foregroundColor: fg,
|
||||
mini: mini,
|
||||
onPressed: handler,
|
||||
child: busy ? AppProgressIndicator.small(color: fg) : Icon(icon),
|
||||
);
|
||||
},
|
||||
onPressed: onPressed,
|
||||
controller: controller,
|
||||
errorBuilder: errorBuilder,
|
||||
onError: onError,
|
||||
onSuccess: onSuccess,
|
||||
builder: (context, busy, handler) {
|
||||
final fg = foregroundColor ?? Theme.of(context).colorScheme.onPrimary;
|
||||
return FloatingActionButton(
|
||||
heroTag: heroTag,
|
||||
backgroundColor: backgroundColor,
|
||||
foregroundColor: fg,
|
||||
mini: mini,
|
||||
onPressed: handler,
|
||||
child: busy ? AppProgressIndicator.small(color: fg) : Icon(icon),
|
||||
);
|
||||
},
|
||||
);
|
||||
}
|
||||
|
||||
@@ -24,23 +24,23 @@ class AsyncIconButton extends StatelessWidget {
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context) => _AsyncMixin(
|
||||
onPressed: onPressed,
|
||||
controller: controller,
|
||||
errorBuilder: errorBuilder,
|
||||
onError: onError,
|
||||
onSuccess: onSuccess,
|
||||
builder: (context, busy, handler) {
|
||||
if (busy) {
|
||||
return Padding(
|
||||
padding: const EdgeInsets.all(12),
|
||||
child: AppProgressIndicator.small(color: color),
|
||||
);
|
||||
}
|
||||
return IconButton(
|
||||
icon: Icon(icon, color: color),
|
||||
tooltip: tooltip,
|
||||
onPressed: handler,
|
||||
);
|
||||
},
|
||||
onPressed: onPressed,
|
||||
controller: controller,
|
||||
errorBuilder: errorBuilder,
|
||||
onError: onError,
|
||||
onSuccess: onSuccess,
|
||||
builder: (context, busy, handler) {
|
||||
if (busy) {
|
||||
return Padding(
|
||||
padding: const EdgeInsets.all(12),
|
||||
child: AppProgressIndicator.small(color: color),
|
||||
);
|
||||
}
|
||||
return IconButton(
|
||||
icon: Icon(icon, color: color),
|
||||
tooltip: tooltip,
|
||||
onPressed: handler,
|
||||
);
|
||||
},
|
||||
);
|
||||
}
|
||||
|
||||
@@ -36,7 +36,10 @@ class _AsyncListTileState extends State<AsyncListTile> {
|
||||
}
|
||||
|
||||
Future<void> _handleTap() async {
|
||||
final ok = await _controller.run(widget.onPressed, errorBuilder: widget.errorBuilder);
|
||||
final ok = await _controller.run(
|
||||
widget.onPressed,
|
||||
errorBuilder: widget.errorBuilder,
|
||||
);
|
||||
if (!mounted) return;
|
||||
if (ok) {
|
||||
widget.onSuccess?.call();
|
||||
@@ -48,38 +51,41 @@ class _AsyncListTileState extends State<AsyncListTile> {
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context) => AnimatedBuilder(
|
||||
animation: _controller,
|
||||
builder: (context, _) {
|
||||
final busy = _controller.busy;
|
||||
final err = _controller.error;
|
||||
final leading = busy
|
||||
? const SizedBox(
|
||||
width: 24,
|
||||
height: 24,
|
||||
child: AppProgressIndicator.small(),
|
||||
)
|
||||
: widget.leading;
|
||||
return Column(
|
||||
mainAxisSize: MainAxisSize.min,
|
||||
crossAxisAlignment: CrossAxisAlignment.stretch,
|
||||
children: [
|
||||
ListTile(
|
||||
leading: leading,
|
||||
title: widget.title,
|
||||
subtitle: widget.subtitle,
|
||||
enabled: widget.enabled && !busy,
|
||||
onTap: busy ? null : _handleTap,
|
||||
),
|
||||
if (err != null)
|
||||
Padding(
|
||||
padding: const EdgeInsets.only(left: 16, right: 16, bottom: 8),
|
||||
child: Text(
|
||||
err,
|
||||
style: TextStyle(color: Theme.of(context).colorScheme.error, fontSize: 13),
|
||||
),
|
||||
animation: _controller,
|
||||
builder: (context, _) {
|
||||
final busy = _controller.busy;
|
||||
final err = _controller.error;
|
||||
final leading = busy
|
||||
? const SizedBox(
|
||||
width: 24,
|
||||
height: 24,
|
||||
child: AppProgressIndicator.small(),
|
||||
)
|
||||
: widget.leading;
|
||||
return Column(
|
||||
mainAxisSize: MainAxisSize.min,
|
||||
crossAxisAlignment: CrossAxisAlignment.stretch,
|
||||
children: [
|
||||
ListTile(
|
||||
leading: leading,
|
||||
title: widget.title,
|
||||
subtitle: widget.subtitle,
|
||||
enabled: widget.enabled && !busy,
|
||||
onTap: busy ? null : _handleTap,
|
||||
),
|
||||
if (err != null)
|
||||
Padding(
|
||||
padding: const EdgeInsets.only(left: 16, right: 16, bottom: 8),
|
||||
child: Text(
|
||||
err,
|
||||
style: TextStyle(
|
||||
color: Theme.of(context).colorScheme.error,
|
||||
fontSize: 13,
|
||||
),
|
||||
],
|
||||
);
|
||||
},
|
||||
),
|
||||
),
|
||||
],
|
||||
);
|
||||
},
|
||||
);
|
||||
}
|
||||
|
||||
@@ -6,7 +6,8 @@ class _AsyncMixin extends StatefulWidget {
|
||||
final AsyncErrorBuilder? errorBuilder;
|
||||
final void Function(String message)? onError;
|
||||
final VoidCallback? onSuccess;
|
||||
final Widget Function(BuildContext context, bool busy, VoidCallback? handler) builder;
|
||||
final Widget Function(BuildContext context, bool busy, VoidCallback? handler)
|
||||
builder;
|
||||
|
||||
const _AsyncMixin({
|
||||
required this.onPressed,
|
||||
@@ -59,7 +60,10 @@ class _AsyncMixinState extends State<_AsyncMixin> {
|
||||
Future<void> _trigger() async {
|
||||
final action = widget.onPressed;
|
||||
if (action == null) return;
|
||||
final success = await _controller.run(action, errorBuilder: widget.errorBuilder);
|
||||
final success = await _controller.run(
|
||||
action,
|
||||
errorBuilder: widget.errorBuilder,
|
||||
);
|
||||
if (!mounted) return;
|
||||
if (success) {
|
||||
widget.onSuccess?.call();
|
||||
@@ -71,7 +75,11 @@ class _AsyncMixinState extends State<_AsyncMixin> {
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
final handler = widget.onPressed == null ? null : _trigger;
|
||||
return widget.builder(context, _controller.busy, _controller.busy ? null : handler);
|
||||
return widget.builder(
|
||||
context,
|
||||
_controller.busy,
|
||||
_controller.busy ? null : handler,
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -98,7 +106,10 @@ class _InlineErrorWrapper extends StatelessWidget {
|
||||
Text(
|
||||
err,
|
||||
textAlign: TextAlign.center,
|
||||
style: TextStyle(color: Theme.of(context).colorScheme.error, fontSize: 13),
|
||||
style: TextStyle(
|
||||
color: Theme.of(context).colorScheme.error,
|
||||
fontSize: 13,
|
||||
),
|
||||
),
|
||||
],
|
||||
],
|
||||
|
||||
@@ -22,27 +22,27 @@ class AsyncTextButton extends StatelessWidget {
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context) => _AsyncMixin(
|
||||
onPressed: onPressed,
|
||||
controller: controller,
|
||||
errorBuilder: errorBuilder,
|
||||
onError: onError,
|
||||
onSuccess: onSuccess,
|
||||
builder: (context, busy, handler) {
|
||||
final content = busy
|
||||
? Row(
|
||||
mainAxisSize: MainAxisSize.min,
|
||||
children: [
|
||||
AppProgressIndicator.small(
|
||||
color: Theme.of(context).colorScheme.primary,
|
||||
),
|
||||
const SizedBox(width: 8),
|
||||
child,
|
||||
],
|
||||
)
|
||||
: child;
|
||||
final button = TextButton(onPressed: handler, child: content);
|
||||
if (!showInlineError) return button;
|
||||
return _InlineErrorWrapper(controller: controller, child: button);
|
||||
},
|
||||
);
|
||||
onPressed: onPressed,
|
||||
controller: controller,
|
||||
errorBuilder: errorBuilder,
|
||||
onError: onError,
|
||||
onSuccess: onSuccess,
|
||||
builder: (context, busy, handler) {
|
||||
final content = busy
|
||||
? Row(
|
||||
mainAxisSize: MainAxisSize.min,
|
||||
children: [
|
||||
AppProgressIndicator.small(
|
||||
color: Theme.of(context).colorScheme.primary,
|
||||
),
|
||||
const SizedBox(width: 8),
|
||||
child,
|
||||
],
|
||||
)
|
||||
: child;
|
||||
final button = TextButton(onPressed: handler, child: content);
|
||||
if (!showInlineError) return button;
|
||||
return _InlineErrorWrapper(controller: controller, child: button);
|
||||
},
|
||||
);
|
||||
}
|
||||
|
||||
@@ -18,7 +18,8 @@ class Breaker extends StatelessWidget {
|
||||
if (blocked != null) {
|
||||
return PlaceholderView(
|
||||
icon: Icons.app_blocking_outlined,
|
||||
text: 'Die App / Dieser Bereich ist zurzeit nicht verfügbar!\n\n'
|
||||
text:
|
||||
'Die App / Dieser Bereich ist zurzeit nicht verfügbar!\n\n'
|
||||
'${blocked.isEmpty ? "Es wurde vom Server kein Grund übermittelt.\nAktualisiere die App und versuche es später erneut" : blocked}',
|
||||
);
|
||||
}
|
||||
|
||||
@@ -6,8 +6,8 @@ class CenteredLeading extends StatelessWidget {
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context) => Column(
|
||||
mainAxisAlignment: MainAxisAlignment.center,
|
||||
crossAxisAlignment: CrossAxisAlignment.center,
|
||||
children: [child],
|
||||
);
|
||||
mainAxisAlignment: MainAxisAlignment.center,
|
||||
crossAxisAlignment: CrossAxisAlignment.center,
|
||||
children: [child],
|
||||
);
|
||||
}
|
||||
|
||||
@@ -6,7 +6,8 @@ class ClickableAppBar extends StatelessWidget implements PreferredSizeWidget {
|
||||
const ClickableAppBar({required this.onTap, required this.appBar, super.key});
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context) => GestureDetector(onTap: onTap, child: appBar);
|
||||
Widget build(BuildContext context) =>
|
||||
GestureDetector(onTap: onTap, child: appBar);
|
||||
|
||||
@override
|
||||
Size get preferredSize => appBar.preferredSize;
|
||||
|
||||
@@ -23,8 +23,10 @@ class ConfirmDialog extends StatelessWidget {
|
||||
this.onConfirm,
|
||||
this.onConfirmAsync,
|
||||
this.errorBuilder,
|
||||
}) : assert(onConfirm != null || onConfirmAsync != null,
|
||||
'ConfirmDialog requires either onConfirm or onConfirmAsync');
|
||||
}) : assert(
|
||||
onConfirm != null || onConfirmAsync != null,
|
||||
'ConfirmDialog requires either onConfirm or onConfirmAsync',
|
||||
);
|
||||
|
||||
void asDialog(BuildContext context) {
|
||||
showDialog(context: context, builder: build);
|
||||
@@ -32,32 +34,32 @@ class ConfirmDialog extends StatelessWidget {
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context) => AlertDialog(
|
||||
icon: icon != null ? Icon(icon) : null,
|
||||
title: Text(title),
|
||||
content: Text(content),
|
||||
actions: onConfirmAsync != null
|
||||
? [
|
||||
AsyncDialogAction(
|
||||
confirmLabel: confirmButton,
|
||||
cancelLabel: cancelButton,
|
||||
onConfirm: onConfirmAsync!,
|
||||
errorBuilder: errorBuilder,
|
||||
),
|
||||
]
|
||||
: [
|
||||
TextButton(
|
||||
onPressed: () => Navigator.of(context).pop(),
|
||||
child: Text(cancelButton),
|
||||
),
|
||||
TextButton(
|
||||
onPressed: () {
|
||||
Navigator.of(context).pop();
|
||||
onConfirm!();
|
||||
},
|
||||
child: Text(confirmButton),
|
||||
),
|
||||
],
|
||||
);
|
||||
icon: icon != null ? Icon(icon) : null,
|
||||
title: Text(title),
|
||||
content: Text(content),
|
||||
actions: onConfirmAsync != null
|
||||
? [
|
||||
AsyncDialogAction(
|
||||
confirmLabel: confirmButton,
|
||||
cancelLabel: cancelButton,
|
||||
onConfirm: onConfirmAsync!,
|
||||
errorBuilder: errorBuilder,
|
||||
),
|
||||
]
|
||||
: [
|
||||
TextButton(
|
||||
onPressed: () => Navigator.of(context).pop(),
|
||||
child: Text(cancelButton),
|
||||
),
|
||||
TextButton(
|
||||
onPressed: () {
|
||||
Navigator.of(context).pop();
|
||||
onConfirm!();
|
||||
},
|
||||
child: Text(confirmButton),
|
||||
),
|
||||
],
|
||||
);
|
||||
|
||||
static void openBrowser(BuildContext context, String url) {
|
||||
showDialog(
|
||||
@@ -66,7 +68,8 @@ class ConfirmDialog extends StatelessWidget {
|
||||
title: 'Link öffnen',
|
||||
content: 'Möchtest du den folgenden Link öffnen?\n$url',
|
||||
confirmButton: 'Öffnen',
|
||||
onConfirm: () => launchUrl(Uri.parse(url), mode: LaunchMode.externalApplication),
|
||||
onConfirm: () =>
|
||||
launchUrl(Uri.parse(url), mode: LaunchMode.externalApplication),
|
||||
),
|
||||
);
|
||||
}
|
||||
|
||||
@@ -1,4 +1,3 @@
|
||||
|
||||
import 'dart:async';
|
||||
import 'dart:convert';
|
||||
import 'package:filesize/filesize.dart';
|
||||
@@ -21,9 +20,15 @@ class CacheView extends StatefulWidget {
|
||||
}
|
||||
|
||||
Future<int> totalSize() async {
|
||||
final data = await Localstore.instance.collection(RequestCache.collection).get();
|
||||
final data = await Localstore.instance
|
||||
.collection(RequestCache.collection)
|
||||
.get();
|
||||
if (data == null || data.isEmpty) return 0;
|
||||
return data.values.fold<int>(0, (sum, value) => sum + jsonEncode(value).length) * 8;
|
||||
return data.values.fold<int>(
|
||||
0,
|
||||
(sum, value) => sum + jsonEncode(value).length,
|
||||
) *
|
||||
8;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -39,41 +44,45 @@ class _CacheViewState extends State<CacheView> {
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context) => Scaffold(
|
||||
appBar: AppBar(
|
||||
title: const Text('Cache storage'),
|
||||
),
|
||||
body: FutureBuilder(
|
||||
future: files,
|
||||
builder: (context, snapshot) {
|
||||
if(snapshot.hasData) {
|
||||
return ListView.builder(
|
||||
itemCount: snapshot.data!.length,
|
||||
itemBuilder: (context, index) {
|
||||
final key = snapshot.data!.keys.elementAt(index);
|
||||
final element = snapshot.data![key] as Map<String, dynamic>;
|
||||
final filename = key.split('/').last;
|
||||
appBar: AppBar(title: const Text('Cache storage')),
|
||||
body: FutureBuilder(
|
||||
future: files,
|
||||
builder: (context, snapshot) {
|
||||
if (snapshot.hasData) {
|
||||
return ListView.builder(
|
||||
itemCount: snapshot.data!.length,
|
||||
itemBuilder: (context, index) {
|
||||
final key = snapshot.data!.keys.elementAt(index);
|
||||
final element = snapshot.data![key] as Map<String, dynamic>;
|
||||
final filename = key.split('/').last;
|
||||
|
||||
return ListTile(
|
||||
leading: const Icon(Icons.text_snippet_outlined),
|
||||
title: Text(filename),
|
||||
subtitle: Text('${filesize(jsonEncode(element).length * 8)}, ${Jiffy.parseFromMillisecondsSinceEpoch(element['lastupdate'] as int).fromNow()}'),
|
||||
trailing: const Icon(Icons.arrow_right),
|
||||
onTap: () => JsonViewer.asDialog(context, jsonDecode(element['json'] as String) as Map<String, dynamic>),
|
||||
);
|
||||
},
|
||||
);
|
||||
} else if(snapshot.connectionState != ConnectionState.done) {
|
||||
return const Center(
|
||||
child: CircularProgressIndicator()
|
||||
);
|
||||
} else {
|
||||
return const Center(
|
||||
child: PlaceholderView(icon: Icons.hourglass_empty, text: 'Keine Daten'),
|
||||
);
|
||||
}
|
||||
},
|
||||
),
|
||||
);
|
||||
return ListTile(
|
||||
leading: const Icon(Icons.text_snippet_outlined),
|
||||
title: Text(filename),
|
||||
subtitle: Text(
|
||||
'${filesize(jsonEncode(element).length * 8)}, ${Jiffy.parseFromMillisecondsSinceEpoch(element['lastupdate'] as int).fromNow()}',
|
||||
),
|
||||
trailing: const Icon(Icons.arrow_right),
|
||||
onTap: () => JsonViewer.asDialog(
|
||||
context,
|
||||
jsonDecode(element['json'] as String) as Map<String, dynamic>,
|
||||
),
|
||||
);
|
||||
},
|
||||
);
|
||||
} else if (snapshot.connectionState != ConnectionState.done) {
|
||||
return const Center(child: CircularProgressIndicator());
|
||||
} else {
|
||||
return const Center(
|
||||
child: PlaceholderView(
|
||||
icon: Icons.hourglass_empty,
|
||||
text: 'Keine Daten',
|
||||
),
|
||||
);
|
||||
}
|
||||
},
|
||||
),
|
||||
);
|
||||
}
|
||||
|
||||
extension FutureExtension<T> on Future<T> {
|
||||
|
||||
@@ -12,23 +12,29 @@ class DebugTile {
|
||||
DebugTile(this.context, {this.onlyInDebug = false});
|
||||
|
||||
bool devConditionFulfilled() =>
|
||||
context.read<SettingsCubit>().val().devToolsEnabled && (onlyInDebug ? kDebugMode : true);
|
||||
context.read<SettingsCubit>().val().devToolsEnabled &&
|
||||
(onlyInDebug ? kDebugMode : true);
|
||||
|
||||
Widget jsonData(Map<String, dynamic> data, {bool ignoreConfig = false}) => callback(
|
||||
Widget jsonData(Map<String, dynamic> data, {bool ignoreConfig = false}) =>
|
||||
callback(
|
||||
title: 'JSON daten anzeigen',
|
||||
onTab: () => JsonViewer.asDialog(context, data),
|
||||
);
|
||||
|
||||
Widget callback({String title = 'Debugaktion', required void Function() onTab}) => child(
|
||||
ListTile(
|
||||
leading: const CenteredLeading(Icon(Icons.developer_mode_outlined)),
|
||||
title: Text(title),
|
||||
subtitle: const Text('Entwicklermodus aktiviert'),
|
||||
onTap: onTab,
|
||||
),
|
||||
);
|
||||
Widget callback({
|
||||
String title = 'Debugaktion',
|
||||
required void Function() onTab,
|
||||
}) => child(
|
||||
ListTile(
|
||||
leading: const CenteredLeading(Icon(Icons.developer_mode_outlined)),
|
||||
title: Text(title),
|
||||
subtitle: const Text('Entwicklermodus aktiviert'),
|
||||
onTap: onTab,
|
||||
),
|
||||
);
|
||||
|
||||
Widget child(Widget child) => Visibility(visible: devConditionFulfilled(), child: child);
|
||||
Widget child(Widget child) =>
|
||||
Visibility(visible: devConditionFulfilled(), child: child);
|
||||
|
||||
void run(void Function() callback) {
|
||||
if (!devConditionFulfilled()) return;
|
||||
|
||||
@@ -12,35 +12,50 @@ class JsonViewer extends StatelessWidget {
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context) => Scaffold(
|
||||
appBar: AppBar(
|
||||
title: Text(title),
|
||||
),
|
||||
body: SingleChildScrollView(
|
||||
scrollDirection: Axis.vertical,
|
||||
child: Text(format(data)),
|
||||
),
|
||||
);
|
||||
appBar: AppBar(title: Text(title)),
|
||||
body: SingleChildScrollView(
|
||||
scrollDirection: Axis.vertical,
|
||||
child: Text(format(data)),
|
||||
),
|
||||
);
|
||||
|
||||
static final _encoder = const JsonEncoder.withIndent(' ');
|
||||
|
||||
static String format(Map<String, dynamic> jsonInput) => _encoder.convert(jsonInput);
|
||||
static String format(Map<String, dynamic> jsonInput) =>
|
||||
_encoder.convert(jsonInput);
|
||||
|
||||
static void asDialog(BuildContext context, Map<String, dynamic> dataMap) {
|
||||
showDialog(context: context, builder: (dialogCtx) => AlertDialog(
|
||||
showDialog(
|
||||
context: context,
|
||||
builder: (dialogCtx) => AlertDialog(
|
||||
scrollable: true,
|
||||
title: const Row(children: [Icon(Icons.bug_report_outlined), Text('Rohdaten')]),
|
||||
title: const Row(
|
||||
children: [Icon(Icons.bug_report_outlined), Text('Rohdaten')],
|
||||
),
|
||||
content: Text(JsonViewer.format(dataMap)),
|
||||
actions: [
|
||||
TextButton(
|
||||
onPressed: () => copyToClipboard(dialogCtx, JsonViewer.format(dataMap), successMessage: 'Formatiertes JSON kopiert'),
|
||||
onPressed: () => copyToClipboard(
|
||||
dialogCtx,
|
||||
JsonViewer.format(dataMap),
|
||||
successMessage: 'Formatiertes JSON kopiert',
|
||||
),
|
||||
child: const Text('Kopieren'),
|
||||
),
|
||||
TextButton(
|
||||
onPressed: () => copyToClipboard(dialogCtx, dataMap.toString(), successMessage: 'Inline JSON kopiert'),
|
||||
onPressed: () => copyToClipboard(
|
||||
dialogCtx,
|
||||
dataMap.toString(),
|
||||
successMessage: 'Inline JSON kopiert',
|
||||
),
|
||||
child: const Text('Inline Kopieren'),
|
||||
),
|
||||
TextButton(onPressed: () => Navigator.of(dialogCtx).pop(), child: const Text('Schließen'))
|
||||
TextButton(
|
||||
onPressed: () => Navigator.of(dialogCtx).pop(),
|
||||
child: const Text('Schließen'),
|
||||
),
|
||||
],
|
||||
));
|
||||
),
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -21,10 +21,7 @@ void showDetailsBottomSheet(
|
||||
mainAxisSize: MainAxisSize.min,
|
||||
crossAxisAlignment: CrossAxisAlignment.stretch,
|
||||
children: [
|
||||
if (header != null) ...[
|
||||
header,
|
||||
const Divider(height: 1),
|
||||
],
|
||||
if (header != null) ...[header, const Divider(height: 1)],
|
||||
...children(sheetContext),
|
||||
],
|
||||
),
|
||||
|
||||
@@ -9,7 +9,8 @@ class FilePick {
|
||||
return pickedImages.isNotEmpty ? pickedImages : null;
|
||||
}
|
||||
|
||||
static Future<XFile?> cameraPick() => _picker.pickImage(source: ImageSource.camera);
|
||||
static Future<XFile?> cameraPick() =>
|
||||
_picker.pickImage(source: ImageSource.camera);
|
||||
|
||||
static Future<List<String>?> documentPick() async {
|
||||
final result = await FilePicker.pickFiles(allowMultiple: true);
|
||||
|
||||
+93
-78
@@ -25,11 +25,7 @@ class FileViewer extends StatefulWidget {
|
||||
State<FileViewer> createState() => _FileViewerState();
|
||||
}
|
||||
|
||||
enum FileViewingActions {
|
||||
openExternal,
|
||||
share,
|
||||
save
|
||||
}
|
||||
enum FileViewingActions { openExternal, share, save }
|
||||
|
||||
/// Workaround for a Syncfusion PDF viewer race: SfPdfViewer's internal
|
||||
/// LayoutBuilder calls `localToGlobal` during build, which asserts when an
|
||||
@@ -88,7 +84,9 @@ class _FileViewerState extends State<FileViewer> {
|
||||
|
||||
@override
|
||||
void initState() {
|
||||
openExternal = settings.val().fileViewSettings.alwaysOpenExternally || widget.openExternal;
|
||||
openExternal =
|
||||
settings.val().fileViewSettings.alwaysOpenExternally ||
|
||||
widget.openExternal;
|
||||
super.initState();
|
||||
}
|
||||
|
||||
@@ -101,96 +99,113 @@ class _FileViewerState extends State<FileViewer> {
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
AppBar appbar({List<Widget> actions = const []}) => AppBar(
|
||||
title: Text(widget.path.split('/').last),
|
||||
actions: [
|
||||
...actions,
|
||||
PopupMenuButton<FileViewingActions>(
|
||||
onSelected: (value) async {
|
||||
switch(value) {
|
||||
case FileViewingActions.openExternal:
|
||||
AppRoutes.openFileViewer(context, widget.path, openExternal: true);
|
||||
break;
|
||||
case FileViewingActions.share:
|
||||
unawaited(SharePlus.instance.share(
|
||||
title: Text(widget.path.split('/').last),
|
||||
actions: [
|
||||
...actions,
|
||||
PopupMenuButton<FileViewingActions>(
|
||||
onSelected: (value) async {
|
||||
switch (value) {
|
||||
case FileViewingActions.openExternal:
|
||||
AppRoutes.openFileViewer(
|
||||
context,
|
||||
widget.path,
|
||||
openExternal: true,
|
||||
);
|
||||
break;
|
||||
case FileViewingActions.share:
|
||||
unawaited(
|
||||
SharePlus.instance.share(
|
||||
ShareParams(
|
||||
files: [XFile(widget.path)],
|
||||
sharePositionOrigin: SharePositionOrigin.get(context),
|
||||
),
|
||||
));
|
||||
break;
|
||||
case FileViewingActions.save:
|
||||
try {
|
||||
final bytes = await File(widget.path).readAsBytes();
|
||||
final saved = await FilePicker.saveFile(
|
||||
fileName: widget.path.split('/').last,
|
||||
bytes: bytes,
|
||||
);
|
||||
if (!context.mounted) return;
|
||||
if (saved != null) InfoDialog.show(context, 'Datei gespeichert.');
|
||||
} on Object catch (e) {
|
||||
if (!context.mounted) return;
|
||||
InfoDialog.show(context, 'Speichern fehlgeschlagen: $e', copyable: true, title: 'Fehler');
|
||||
),
|
||||
);
|
||||
break;
|
||||
case FileViewingActions.save:
|
||||
try {
|
||||
final bytes = await File(widget.path).readAsBytes();
|
||||
final saved = await FilePicker.saveFile(
|
||||
fileName: widget.path.split('/').last,
|
||||
bytes: bytes,
|
||||
);
|
||||
if (!context.mounted) return;
|
||||
if (saved != null) {
|
||||
InfoDialog.show(context, 'Datei gespeichert.');
|
||||
}
|
||||
break;
|
||||
}
|
||||
},
|
||||
itemBuilder: (context) => <PopupMenuEntry<FileViewingActions>>[
|
||||
const PopupMenuItem(
|
||||
value: FileViewingActions.openExternal,
|
||||
child: ListTile(
|
||||
leading: Icon(Icons.open_in_new),
|
||||
title: Text('Extern öffnen'),
|
||||
dense: true,
|
||||
),
|
||||
} on Object catch (e) {
|
||||
if (!context.mounted) return;
|
||||
InfoDialog.show(
|
||||
context,
|
||||
'Speichern fehlgeschlagen: $e',
|
||||
copyable: true,
|
||||
title: 'Fehler',
|
||||
);
|
||||
}
|
||||
break;
|
||||
}
|
||||
},
|
||||
itemBuilder: (context) => <PopupMenuEntry<FileViewingActions>>[
|
||||
const PopupMenuItem(
|
||||
value: FileViewingActions.openExternal,
|
||||
child: ListTile(
|
||||
leading: Icon(Icons.open_in_new),
|
||||
title: Text('Extern öffnen'),
|
||||
dense: true,
|
||||
),
|
||||
const PopupMenuItem(
|
||||
value: FileViewingActions.share,
|
||||
child: ListTile(
|
||||
leading: Icon(Icons.share_outlined),
|
||||
title: Text('Teilen'),
|
||||
dense: true,
|
||||
),
|
||||
),
|
||||
const PopupMenuItem(
|
||||
value: FileViewingActions.share,
|
||||
child: ListTile(
|
||||
leading: Icon(Icons.share_outlined),
|
||||
title: Text('Teilen'),
|
||||
dense: true,
|
||||
),
|
||||
const PopupMenuItem(
|
||||
value: FileViewingActions.save,
|
||||
child: ListTile(
|
||||
leading: Icon(Icons.save_alt_outlined),
|
||||
title: Text('Speichern'),
|
||||
dense: true,
|
||||
),
|
||||
),
|
||||
const PopupMenuItem(
|
||||
value: FileViewingActions.save,
|
||||
child: ListTile(
|
||||
leading: Icon(Icons.save_alt_outlined),
|
||||
title: Text('Speichern'),
|
||||
dense: true,
|
||||
),
|
||||
],
|
||||
),
|
||||
],
|
||||
);
|
||||
),
|
||||
],
|
||||
),
|
||||
],
|
||||
);
|
||||
|
||||
switch(openExternal ? '' : widget.path.split('.').last.toLowerCase()) {
|
||||
switch (openExternal ? '' : widget.path.split('.').last.toLowerCase()) {
|
||||
case 'png':
|
||||
case 'jpg':
|
||||
case 'jpeg':
|
||||
case 'webp':
|
||||
case 'gif':
|
||||
return Scaffold(
|
||||
appBar: appbar(
|
||||
actions: [
|
||||
IconButton(onPressed: () {
|
||||
setState(() {
|
||||
photoViewController.rotation += pi/2;
|
||||
});
|
||||
}, icon: const Icon(Icons.rotate_right)),
|
||||
]
|
||||
appBar: appbar(
|
||||
actions: [
|
||||
IconButton(
|
||||
onPressed: () {
|
||||
setState(() {
|
||||
photoViewController.rotation += pi / 2;
|
||||
});
|
||||
},
|
||||
icon: const Icon(Icons.rotate_right),
|
||||
),
|
||||
],
|
||||
),
|
||||
backgroundColor: Colors.white,
|
||||
body: PhotoView(
|
||||
controller: photoViewController,
|
||||
maxScale: 3.0,
|
||||
minScale: 0.1,
|
||||
imageProvider: Image.file(File(widget.path)).image,
|
||||
backgroundDecoration: BoxDecoration(
|
||||
color: Theme.of(context).colorScheme.surface,
|
||||
),
|
||||
backgroundColor: Colors.white,
|
||||
body: PhotoView(
|
||||
controller: photoViewController,
|
||||
maxScale: 3.0,
|
||||
minScale: 0.1,
|
||||
imageProvider: Image.file(File(widget.path)).image,
|
||||
backgroundDecoration: BoxDecoration(color: Theme.of(context).colorScheme.surface),
|
||||
)
|
||||
),
|
||||
);
|
||||
|
||||
|
||||
case 'pdf':
|
||||
return Scaffold(
|
||||
appBar: appbar(),
|
||||
|
||||
@@ -9,12 +9,14 @@ class LargeProfilePictureView extends StatelessWidget {
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context) => Scaffold(
|
||||
appBar: AppBar(
|
||||
title: const Text('Profilbild'),
|
||||
appBar: AppBar(title: const Text('Profilbild')),
|
||||
body: PhotoView(
|
||||
imageProvider: Image.network(
|
||||
'https://${EndpointData().nextcloud().full()}/avatar/$username/1024',
|
||||
).image,
|
||||
backgroundDecoration: BoxDecoration(
|
||||
color: Theme.of(context).colorScheme.surface,
|
||||
),
|
||||
body: PhotoView(
|
||||
imageProvider: Image.network('https://${EndpointData().nextcloud().full()}/avatar/$username/1024').image,
|
||||
backgroundDecoration: BoxDecoration(color: Theme.of(context).colorScheme.surface),
|
||||
),
|
||||
);
|
||||
),
|
||||
);
|
||||
}
|
||||
|
||||
@@ -1,9 +1,10 @@
|
||||
|
||||
import 'package:flutter/material.dart';
|
||||
|
||||
class ListViewUtil {
|
||||
static ListView fromList<T>(List<T>? items, Widget Function(T item) map) => ListView.builder(
|
||||
itemCount: items?.length ?? 0,
|
||||
itemBuilder: (context, index) => items != null ? map(items[index]) : null,
|
||||
);
|
||||
static ListView fromList<T>(List<T>? items, Widget Function(T item) map) =>
|
||||
ListView.builder(
|
||||
itemCount: items?.length ?? 0,
|
||||
itemBuilder: (context, index) =>
|
||||
items != null ? map(items[index]) : null,
|
||||
);
|
||||
}
|
||||
|
||||
@@ -1,4 +1,3 @@
|
||||
|
||||
import 'dart:async';
|
||||
|
||||
import 'package:flutter/material.dart';
|
||||
@@ -16,7 +15,7 @@ class _LoadingSpinnerState extends State<LoadingSpinner> {
|
||||
|
||||
@override
|
||||
void initState() {
|
||||
timer = Timer(const Duration(seconds: 30), () {
|
||||
timer = Timer(const Duration(seconds: 30), () {
|
||||
setState(() {
|
||||
textVisible = true;
|
||||
});
|
||||
@@ -27,25 +26,25 @@ class _LoadingSpinnerState extends State<LoadingSpinner> {
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context) => Center(
|
||||
child: Column(
|
||||
mainAxisAlignment: MainAxisAlignment.center,
|
||||
children: [
|
||||
Visibility(
|
||||
visible: !textVisible,
|
||||
replacement: const Icon(Icons.sentiment_dissatisfied_outlined),
|
||||
child: const CircularProgressIndicator(),
|
||||
child: Column(
|
||||
mainAxisAlignment: MainAxisAlignment.center,
|
||||
children: [
|
||||
Visibility(
|
||||
visible: !textVisible,
|
||||
replacement: const Icon(Icons.sentiment_dissatisfied_outlined),
|
||||
child: const CircularProgressIndicator(),
|
||||
),
|
||||
const SizedBox(height: 30),
|
||||
Visibility(
|
||||
visible: textVisible,
|
||||
child: const Text(
|
||||
textAlign: TextAlign.center,
|
||||
'Irgendetwas funktioniert nicht!\nBist du mit dem Internet verbunden?\n\nVersuche die App neuzustarten',
|
||||
),
|
||||
const SizedBox(height: 30),
|
||||
Visibility(
|
||||
visible: textVisible,
|
||||
child: const Text(
|
||||
textAlign: TextAlign.center,
|
||||
'Irgendetwas funktioniert nicht!\nBist du mit dem Internet verbunden?\n\nVersuche die App neuzustarten'
|
||||
),
|
||||
),
|
||||
],
|
||||
),
|
||||
);
|
||||
),
|
||||
],
|
||||
),
|
||||
);
|
||||
|
||||
@override
|
||||
void dispose() {
|
||||
|
||||
@@ -4,7 +4,12 @@ class PlaceholderView extends StatelessWidget {
|
||||
final IconData icon;
|
||||
final String text;
|
||||
final Widget? button;
|
||||
const PlaceholderView({super.key, required this.icon, required this.text, this.button});
|
||||
const PlaceholderView({
|
||||
super.key,
|
||||
required this.icon,
|
||||
required this.text,
|
||||
this.button,
|
||||
});
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context) => Scaffold(
|
||||
@@ -19,7 +24,7 @@ class PlaceholderView extends StatelessWidget {
|
||||
),
|
||||
Text(
|
||||
text,
|
||||
style: const TextStyle(fontSize: 20,),
|
||||
style: const TextStyle(fontSize: 20),
|
||||
textAlign: TextAlign.center,
|
||||
),
|
||||
const SizedBox(height: 30),
|
||||
|
||||
@@ -1,5 +1,10 @@
|
||||
import 'package:flutter/material.dart';
|
||||
|
||||
class SharePositionOrigin {
|
||||
static Rect get(BuildContext context) => Rect.fromLTWH(0, 0, MediaQuery.of(context).size.width, MediaQuery.of(context).size.height / 2);
|
||||
static Rect get(BuildContext context) => Rect.fromLTWH(
|
||||
0,
|
||||
0,
|
||||
MediaQuery.of(context).size.width,
|
||||
MediaQuery.of(context).size.height / 2,
|
||||
);
|
||||
}
|
||||
|
||||
@@ -1,3 +1,4 @@
|
||||
extension StringExtensions on String {
|
||||
String capitalize() => '${this[0].toUpperCase()}${substring(1).toLowerCase()}';
|
||||
String capitalize() =>
|
||||
'${this[0].toUpperCase()}${substring(1).toLowerCase()}';
|
||||
}
|
||||
|
||||
@@ -2,6 +2,10 @@ import 'package:flutter/material.dart';
|
||||
|
||||
class UnimplementedDialog {
|
||||
static void show(BuildContext context) {
|
||||
showDialog(context: context, builder: (context) => const AlertDialog(content: Text('Not implemented yet')));
|
||||
showDialog(
|
||||
context: context,
|
||||
builder: (context) =>
|
||||
const AlertDialog(content: Text('Not implemented yet')),
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -12,7 +12,12 @@ class UserAvatar extends StatefulWidget {
|
||||
final String id;
|
||||
final bool isGroup;
|
||||
final int size;
|
||||
const UserAvatar({required this.id, this.isGroup = false, this.size = 20, super.key});
|
||||
const UserAvatar({
|
||||
required this.id,
|
||||
this.isGroup = false,
|
||||
this.size = 20,
|
||||
super.key,
|
||||
});
|
||||
|
||||
@override
|
||||
State<UserAvatar> createState() => _UserAvatarState();
|
||||
@@ -79,10 +84,12 @@ class _UserAvatarState extends State<UserAvatar> {
|
||||
}
|
||||
|
||||
static bool _looksLikeSvg(Uint8List bytes) {
|
||||
final head = utf8.decode(
|
||||
bytes.sublist(0, bytes.length < 256 ? bytes.length : 256),
|
||||
allowMalformed: true,
|
||||
).trimLeft();
|
||||
final head = utf8
|
||||
.decode(
|
||||
bytes.sublist(0, bytes.length < 256 ? bytes.length : 256),
|
||||
allowMalformed: true,
|
||||
)
|
||||
.trimLeft();
|
||||
return head.startsWith('<?xml') || head.startsWith('<svg');
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user