Skip to content

armgit / ente

Public Imported from GitHub
0

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

[auth] minor fix

Aman Raj8870a8ec4a08
diff --git a/auth/lib/models/code_display.dart b/auth/lib/models/code_display.dart
index 2e075da83c..382be73fd2 100644
--- a/auth/lib/models/code_display.dart
+++ b/auth/lib/models/code_display.dart
@@ -1,6 +1,5 @@
import 'dart:convert';
-import 'package:ente_auth/models/all_icon_data.dart';
import 'package:flutter/foundation.dart';
import 'package:logging/logging.dart';
@@ -13,9 +12,8 @@ class CodeDisplay {
String note;
final List<String> tags;
int position;
- String customIconData;
- bool isCustomIcon;
- IconType iconType;
+ String iconSrc;
+ String iconID;
CodeDisplay({
this.pinned = false,
@@ -25,11 +23,12 @@ class CodeDisplay {
this.tags = const [],
this.note = '',
this.position = 0,
- this.customIconData = 'ente',
- this.isCustomIcon = false,
- this.iconType = IconType.simpleIcon,
+ this.iconSrc = 'ente',
+ this.iconID = '',
});
+ bool get isCustomIcon => (iconSrc != '' && iconID != '');
+
// copyWith
CodeDisplay copyWith({
bool? pinned,
@@ -39,9 +38,8 @@ class CodeDisplay {
List<String>? tags,
String? note,
int? position,
- String? customIconData,
- IconType? iconType,
- bool? isCustomIcon,
+ String? iconSrc,
+ String? iconID,
}) {
final bool updatedPinned = pinned ?? this.pinned;
final bool updatedTrashed = trashed ?? this.trashed;
@@ -50,9 +48,8 @@ class CodeDisplay {
final List<String> updatedTags = tags ?? this.tags;
final String updatedNote = note ?? this.note;
final int updatedPosition = position ?? this.position;
- final String updatedIconData = customIconData ?? this.customIconData;
- final bool updatedIsCustomIcon = isCustomIcon ?? this.isCustomIcon;
- final IconType updatedIconType = iconType ?? this.iconType;
+ final String updatedIconSrc = iconSrc ?? this.iconSrc;
+ final String updatedIconID = iconID ?? this.iconID;
return CodeDisplay(
pinned: updatedPinned,
@@ -62,9 +59,8 @@ class CodeDisplay {
tags: updatedTags,
note: updatedNote,
position: updatedPosition,
- customIconData: updatedIconData,
- isCustomIcon: updatedIsCustomIcon,
- iconType: updatedIconType,
+ iconSrc: updatedIconSrc,
+ iconID: updatedIconID,
);
}
@@ -80,11 +76,8 @@ class CodeDisplay {
tags: List<String>.from(json['tags'] ?? []),
note: json['note'] ?? '',
position: json['position'] ?? 0,
- customIconData: json['customIconData'] ?? 'ente',
- isCustomIcon: json['isCustomIcon'] ?? false,
- iconType: json['iconType'] == 'simpleIcon'
- ? IconType.simpleIcon
- : IconType.customIcon,
+ iconSrc: json['iconSrc'] ?? 'ente',
+ iconID: json['iconID'] ?? '',
);
}
@@ -127,9 +120,8 @@ class CodeDisplay {
'tags': tags,
'note': note,
'position': position,
- 'customIconData': customIconData,
- 'isCustomIcon': isCustomIcon,
- 'iconType': iconType == IconType.simpleIcon ? 'simpleIcon' : 'customIcon',
+ 'iconSrc': iconSrc,
+ 'iconID': iconID,
};
}
diff --git a/auth/lib/onboarding/view/setup_enter_secret_key_page.dart b/auth/lib/onboarding/view/setup_enter_secret_key_page.dart
index c0a247f59d..72bfa76443 100644
--- a/auth/lib/onboarding/view/setup_enter_secret_key_page.dart
+++ b/auth/lib/onboarding/view/setup_enter_secret_key_page.dart
@@ -47,8 +47,8 @@ class _SetupEnterSecretKeyPageState extends State<SetupEnterSecretKeyPage> {
List<String> allTags = [];
StreamSubscription<CodesUpdatedEvent>? _streamSubscription;
bool isCustomIcon = false;
- String _customIcon = "";
- late IconType _iconType;
+ String _customIconSrc = "";
+ late IconType _iconID;
@override
void initState() {
@@ -90,8 +90,11 @@ class _SetupEnterSecretKeyPageState extends State<SetupEnterSecretKeyPage> {
}
isCustomIcon = widget.code?.display.isCustomIcon ?? false;
- _customIcon = widget.code?.display.customIconData ?? "ente";
- _iconType = widget.code?.display.iconType ?? IconType.simpleIcon;
+ _customIconSrc = widget.code?.display.iconSrc ?? "ente";
+ _iconID = widget.code?.display.iconID == "simpleIcon"
+ ? IconType.simpleIcon
+ : IconType.customIcon;
+
super.initState();
}
@@ -322,7 +325,7 @@ class _SetupEnterSecretKeyPageState extends State<SetupEnterSecretKeyPage> {
children: [
CustomIconWidget(
isCustomIcon: isCustomIcon,
- iconData: _customIcon,
+ iconData: _customIconSrc,
onTap: () {
setState(() {
isCustomIcon = true;
@@ -374,11 +377,11 @@ class _SetupEnterSecretKeyPageState extends State<SetupEnterSecretKeyPage> {
CodeDisplay(tags: selectedTags);
display.note = notes;
if (isCustomIcon) {
- display.isCustomIcon = true;
- display.customIconData = _customIcon.toLowerCase();
- display.iconType = _iconType;
+ display.iconSrc = _customIconSrc.toLowerCase();
+ display.iconID =
+ _iconID == IconType.simpleIcon ? 'simpleIcon' : 'customIcon';
} else {
- display.isCustomIcon = false;
+ display.iconID = '';
}
if (widget.code != null && widget.code!.secret != secret) {
ButtonResult? result = await showChoiceActionSheet(
@@ -435,7 +438,7 @@ class _SetupEnterSecretKeyPageState extends State<SetupEnterSecretKeyPage> {
final allIcons = IconUtils.instance.getAllIcons();
String currentIcon;
if (widget.code!.display.isCustomIcon) {
- currentIcon = widget.code!.display.customIconData;
+ currentIcon = widget.code!.display.iconSrc;
} else {
currentIcon = widget.code!.issuer;
}
@@ -450,8 +453,8 @@ class _SetupEnterSecretKeyPageState extends State<SetupEnterSecretKeyPage> {
),
);
setState(() {
- _customIcon = newCustomIcon.title;
- _iconType = newCustomIcon.type;
+ _customIconSrc = newCustomIcon.title;
+ _iconID = newCustomIcon.type;
});
}
}
diff --git a/auth/lib/ui/code_widget.dart b/auth/lib/ui/code_widget.dart
index 5f2bdf9d70..40147003e1 100644
--- a/auth/lib/ui/code_widget.dart
+++ b/auth/lib/ui/code_widget.dart
@@ -444,7 +444,7 @@ class _CodeWidgetState extends State<CodeWidget> {
Widget _getIcon() {
final String iconData;
if (widget.code.display.isCustomIcon) {
- iconData = widget.code.display.customIconData;
+ iconData = widget.code.display.iconSrc;
} else {
iconData = widget.code.issuer;
}