Skip to content

armgit / ente

Public Imported from GitHub
0

πŸ’š End-to-end encrypted cloud for everything.

Add desktop QR image import entry points

Neeraj Guptaaa6c25bdc124
diff --git a/mobile/apps/auth/changes/desktop-qr-image-import.md b/mobile/apps/auth/changes/desktop-qr-image-import.md
new file mode 100644
index 0000000000..06abcccf3d
--- /dev/null
+++ b/mobile/apps/auth/changes/desktop-qr-image-import.md
@@ -0,0 +1 @@
+- Added support for importing 2FA codes from QR code images on desktop.
diff --git a/mobile/apps/auth/lib/ui/home/home_empty_state.dart b/mobile/apps/auth/lib/ui/home/home_empty_state.dart
index 52b4c67779..b48a373b1c 100644
--- a/mobile/apps/auth/lib/ui/home/home_empty_state.dart
+++ b/mobile/apps/auth/lib/ui/home/home_empty_state.dart
@@ -10,11 +10,13 @@ import 'package:flutter_svg/flutter_svg.dart';
class HomeEmptyStateWidget extends StatelessWidget {
final VoidCallback? onScanTap;
+ final VoidCallback? onImportImageTap;
final VoidCallback? onManuallySetupTap;
const HomeEmptyStateWidget({
super.key,
required this.onScanTap,
+ required this.onImportImageTap,
required this.onManuallySetupTap,
});
@@ -107,12 +109,20 @@ class HomeEmptyStateWidget extends StatelessWidget {
width: double.infinity,
type: RoundedButtonType.secondary,
),
- ] else
+ ] else ...[
+ RoundedButton(
+ label: l10n.importFromGallery,
+ onPressed: onImportImageTap,
+ width: double.infinity,
+ ),
+ const SizedBox(height: 12),
RoundedButton(
label: l10n.importEnterSetupKey,
onPressed: onManuallySetupTap,
width: double.infinity,
+ type: RoundedButtonType.secondary,
),
+ ],
const SizedBox(height: 16),
Row(
mainAxisAlignment: MainAxisAlignment.spaceBetween,
diff --git a/mobile/apps/auth/lib/ui/home_page.dart b/mobile/apps/auth/lib/ui/home_page.dart
index a81568668a..2fe625894a 100644
--- a/mobile/apps/auth/lib/ui/home_page.dart
+++ b/mobile/apps/auth/lib/ui/home_page.dart
@@ -1747,6 +1747,7 @@ class _HomePageState extends State<HomePage> {
if (_filteredCodes.isEmpty && _searchText.isEmpty && noCodesAnywhere) {
return HomeEmptyStateWidget(
onScanTap: _redirectToScannerPage,
+ onImportImageTap: _importFromGalleryNative,
onManuallySetupTap: _redirectToManualEntryPage,
);
} else {
@@ -2322,14 +2323,7 @@ class _HomePageState extends State<HomePage> {
}
Widget _getFab() {
- if (PlatformDetector.isDesktop()) {
- return FloatingActionButton(
- onPressed: () => _redirectToManualEntryPage(),
- elevation: 8.0,
- shape: const CircleBorder(),
- child: const Icon(Icons.add),
- );
- }
+ final isDesktop = PlatformDetector.isDesktop();
return SpeedDial(
icon: Icons.add,
activeIcon: Icons.close,
@@ -2344,13 +2338,14 @@ class _HomePageState extends State<HomePage> {
elevation: 8.0,
animationCurve: Curves.elasticInOut,
children: [
- SpeedDialChild(
- child: const HugeIcon(icon: HugeIcons.strokeRoundedQrCode),
- foregroundColor: Theme.of(context).colorScheme.fabForegroundColor,
- backgroundColor: Theme.of(context).colorScheme.fabBackgroundColor,
- labelWidget: SpeedDialLabelWidget(context.l10n.scanAQrCode),
- onTap: _redirectToScannerPage,
- ),
+ if (!isDesktop)
+ SpeedDialChild(
+ child: const HugeIcon(icon: HugeIcons.strokeRoundedQrCode),
+ foregroundColor: Theme.of(context).colorScheme.fabForegroundColor,
+ backgroundColor: Theme.of(context).colorScheme.fabBackgroundColor,
+ labelWidget: SpeedDialLabelWidget(context.l10n.scanAQrCode),
+ onTap: _redirectToScannerPage,
+ ),
SpeedDialChild(
child: const Icon(Icons.keyboard_alt_outlined),
foregroundColor: Theme.of(context).colorScheme.fabForegroundColor,
@@ -2358,7 +2353,7 @@ class _HomePageState extends State<HomePage> {
labelWidget: SpeedDialLabelWidget(context.l10n.enterDetailsManually),
onTap: _redirectToManualEntryPage,
),
- if (PlatformDetector.isMobile())
+ if (isDesktop || PlatformDetector.isMobile())
SpeedDialChild(
child: const HugeIcon(icon: HugeIcons.strokeRoundedAlbum02),
backgroundColor: Theme.of(context).colorScheme.fabBackgroundColor,