mirror of
https://github.com/Yubico/yubioath-flutter.git
synced 2024-12-23 10:11:52 +03:00
Change subTitle
to subtitle
and make overlay
required.
This commit is contained in:
parent
33be7edbf0
commit
ec1459315d
@ -51,7 +51,8 @@ class AppPage extends StatelessWidget {
|
||||
this.onFileDropped,
|
||||
this.delayedContent = false,
|
||||
this.keyActionsBadge = false,
|
||||
});
|
||||
}) : assert(!(onFileDropped != null && fileDropOverlay == null),
|
||||
'Declaring onFileDropped requires declaring a fileDropOverlay');
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context) => LayoutBuilder(
|
||||
@ -209,7 +210,7 @@ class AppPage extends StatelessWidget {
|
||||
child: onFileDropped != null
|
||||
? FileDropTarget(
|
||||
onFileDropped: onFileDropped!,
|
||||
overlay: fileDropOverlay,
|
||||
overlay: fileDropOverlay!,
|
||||
child: body,
|
||||
)
|
||||
: body,
|
||||
@ -276,7 +277,7 @@ class AppPage extends StatelessWidget {
|
||||
Expanded(
|
||||
child: FileDropTarget(
|
||||
onFileDropped: onFileDropped!,
|
||||
overlay: fileDropOverlay,
|
||||
overlay: fileDropOverlay!,
|
||||
child: body,
|
||||
),
|
||||
)
|
||||
|
@ -71,7 +71,7 @@ class _AddAccountDialogState extends ConsumerState<AddAccountDialog> {
|
||||
},
|
||||
overlay: FileDropOverlay(
|
||||
title: l10n.s_add_account,
|
||||
subTitle: l10n.l_drop_qr_description,
|
||||
subtitle: l10n.l_drop_qr_description,
|
||||
),
|
||||
child: ResponsiveDialog(
|
||||
title: Text(l10n.s_add_account),
|
||||
|
@ -340,7 +340,7 @@ class _OathAddAccountPageState extends ConsumerState<OathAddAccountPage> {
|
||||
},
|
||||
overlay: FileDropOverlay(
|
||||
title: l10n.s_add_account,
|
||||
subTitle: l10n.l_drop_qr_description,
|
||||
subtitle: l10n.l_drop_qr_description,
|
||||
),
|
||||
child: ResponsiveDialog(
|
||||
title: Text(l10n.s_add_account),
|
||||
|
@ -133,15 +133,15 @@ class _UnlockedViewState extends ConsumerState<_UnlockedView> {
|
||||
final hasActions = ref.watch(featureProvider)(features.actions);
|
||||
|
||||
Future<void> onFileDropped(List<int> fileData) async {
|
||||
final qrScanner = ref.watch(qrScannerProvider);
|
||||
final withContext = ref.read(withContextProvider);
|
||||
final credentials = ref.read(credentialsProvider);
|
||||
final qrScanner = ref.read(qrScannerProvider);
|
||||
if (qrScanner != null) {
|
||||
final b64Image = base64Encode(fileData);
|
||||
final qrData = await qrScanner.scanQr(b64Image);
|
||||
final withContext = ref.read(withContextProvider);
|
||||
await withContext(
|
||||
(context) async {
|
||||
if (qrData != null) {
|
||||
final credentials = ref.read(credentialsProvider);
|
||||
await handleUri(context, credentials, qrData, widget.devicePath,
|
||||
widget.oathState, l10n);
|
||||
} else {
|
||||
@ -167,7 +167,7 @@ class _UnlockedViewState extends ConsumerState<_UnlockedView> {
|
||||
onFileDropped: onFileDropped,
|
||||
fileDropOverlay: FileDropOverlay(
|
||||
title: l10n.s_add_account,
|
||||
subTitle: l10n.l_drop_qr_description,
|
||||
subtitle: l10n.l_drop_qr_description,
|
||||
),
|
||||
);
|
||||
}
|
||||
@ -253,7 +253,7 @@ class _UnlockedViewState extends ConsumerState<_UnlockedView> {
|
||||
onFileDropped: onFileDropped,
|
||||
fileDropOverlay: FileDropOverlay(
|
||||
title: l10n.s_add_account,
|
||||
subTitle: l10n.l_drop_qr_description,
|
||||
subtitle: l10n.l_drop_qr_description,
|
||||
),
|
||||
centered: numCreds == null,
|
||||
delayedContent: numCreds == null,
|
||||
|
@ -3,51 +3,47 @@ import 'package:flutter/material.dart';
|
||||
class FileDropOverlay extends StatelessWidget {
|
||||
final Widget? graphic;
|
||||
final String? title;
|
||||
final String? subTitle;
|
||||
final String? subtitle;
|
||||
|
||||
const FileDropOverlay({super.key, this.graphic, this.title, this.subTitle});
|
||||
const FileDropOverlay({super.key, this.graphic, this.title, this.subtitle});
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
return Positioned.fill(
|
||||
child: Padding(
|
||||
padding: const EdgeInsets.all(8.0),
|
||||
child: Container(
|
||||
decoration: BoxDecoration(
|
||||
color: Theme.of(context)
|
||||
.colorScheme
|
||||
.secondaryContainer
|
||||
.withOpacity(0.95),
|
||||
border: Border.all(color: Theme.of(context).colorScheme.primary),
|
||||
borderRadius: const BorderRadius.all(Radius.circular(20.0))),
|
||||
child: Column(
|
||||
mainAxisAlignment: MainAxisAlignment.center,
|
||||
children: [
|
||||
graphic ??
|
||||
Icon(
|
||||
Icons.upload_file,
|
||||
size: 120,
|
||||
color: Theme.of(context).colorScheme.primary,
|
||||
),
|
||||
if (title != null) ...[
|
||||
const SizedBox(height: 16.0),
|
||||
Text(
|
||||
title!,
|
||||
textAlign: TextAlign.center,
|
||||
style: Theme.of(context).textTheme.titleLarge,
|
||||
)
|
||||
],
|
||||
if (subTitle != null) ...[
|
||||
const SizedBox(height: 12.0),
|
||||
Text(
|
||||
subTitle!,
|
||||
textAlign: TextAlign.center,
|
||||
style: Theme.of(context).textTheme.titleSmall,
|
||||
)
|
||||
]
|
||||
return Container(
|
||||
decoration: BoxDecoration(
|
||||
color: Theme.of(context)
|
||||
.colorScheme
|
||||
.secondaryContainer
|
||||
.withOpacity(0.95),
|
||||
border: Border.all(color: Theme.of(context).colorScheme.primary),
|
||||
borderRadius: const BorderRadius.all(Radius.circular(20.0))),
|
||||
child: Column(
|
||||
mainAxisAlignment: MainAxisAlignment.center,
|
||||
children: [
|
||||
graphic ??
|
||||
Icon(
|
||||
Icons.upload_file,
|
||||
size: 120,
|
||||
color: Theme.of(context).colorScheme.primary,
|
||||
),
|
||||
if (title != null) ...[
|
||||
const SizedBox(height: 16.0),
|
||||
Text(
|
||||
title!,
|
||||
textAlign: TextAlign.center,
|
||||
style: Theme.of(context).textTheme.titleLarge,
|
||||
)
|
||||
],
|
||||
),
|
||||
if (subtitle != null) ...[
|
||||
const SizedBox(height: 12.0),
|
||||
Text(
|
||||
subtitle!,
|
||||
textAlign: TextAlign.center,
|
||||
style: Theme.of(context).textTheme.titleSmall,
|
||||
)
|
||||
]
|
||||
],
|
||||
),
|
||||
));
|
||||
);
|
||||
}
|
||||
}
|
||||
|
@ -22,13 +22,13 @@ import '../core/state.dart';
|
||||
class FileDropTarget extends StatefulWidget {
|
||||
final Widget child;
|
||||
final Function(List<int> filedata) onFileDropped;
|
||||
final Widget? overlay;
|
||||
final Widget overlay;
|
||||
|
||||
const FileDropTarget({
|
||||
super.key,
|
||||
required this.child,
|
||||
required this.onFileDropped,
|
||||
this.overlay,
|
||||
required this.overlay,
|
||||
});
|
||||
|
||||
@override
|
||||
@ -38,17 +38,6 @@ class FileDropTarget extends StatefulWidget {
|
||||
class _FileDropTargetState extends State<FileDropTarget> {
|
||||
bool _hovering = false;
|
||||
|
||||
Widget _buildDefaultOverlay() => Positioned.fill(
|
||||
child: Container(
|
||||
color: Colors.blue.withOpacity(0.4),
|
||||
child: Icon(
|
||||
Icons.upload_file,
|
||||
size: 200,
|
||||
color: Colors.black.withOpacity(0.6),
|
||||
),
|
||||
),
|
||||
);
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
return DropTarget(
|
||||
@ -77,7 +66,13 @@ class _FileDropTargetState extends State<FileDropTarget> {
|
||||
child: Stack(
|
||||
children: [
|
||||
widget.child,
|
||||
if (_hovering) widget.overlay ?? _buildDefaultOverlay(),
|
||||
if (_hovering)
|
||||
Positioned.fill(
|
||||
child: Padding(
|
||||
padding: const EdgeInsets.all(8.0),
|
||||
child: widget.overlay,
|
||||
),
|
||||
)
|
||||
],
|
||||
),
|
||||
);
|
||||
|
Loading…
Reference in New Issue
Block a user