Skip to content
This repository was archived by the owner on Oct 6, 2023. It is now read-only.

Commit 6ce57e3

Browse files
committed
Improved performance and added 'other accounts' listing
1 parent ecfc691 commit 6ce57e3

File tree

6 files changed

+71
-35
lines changed

6 files changed

+71
-35
lines changed

Shared/Views/AccountView/AccountView.swift

Lines changed: 44 additions & 28 deletions
Original file line numberDiff line numberDiff line change
@@ -38,38 +38,54 @@ struct AccountView: View {
3838

3939
// MARK: - View
4040
var body: some View {
41-
// let otherAccounts = accounts.filter({ $0.username != account.username }).map({ $0 })
41+
let otherAccounts = accounts.filter({ $0.username != account.username }).map({ $0 })
42+
43+
let columns: [GridItem] = {
44+
#if os(macOS)
45+
return [.init(), .init()]
46+
#else
47+
return UIDevice.current.userInterfaceIdiom == .pad ? [.init(), .init()] : [.init()]
48+
#endif
49+
}()
4250

4351
ScrollView {
4452
content
4553

46-
// VStack {
47-
// if !otherAccounts.isEmpty {
48-
// Text("Other Accounts")
49-
// .frame(maxWidth: .infinity, alignment: .leading)
50-
// LazyVStack {
51-
// ForEach(otherAccounts) { account in
52-
// NavigationLink {
53-
// AccountView(account: account)
54-
// } label: {
55-
// GroupBox {
56-
// HStack {
57-
// FaviconView(website: "https://" + account.domain)
58-
// .frame(width: 40, height: 40)
59-
// VStack(alignment: .leading) {
60-
// Text(account.domain)
61-
// .bold()
62-
// .frame(maxWidth: .infinity, alignment: .leading)
63-
// Text(account.username)
64-
// .foregroundColor(Color.secondary)
65-
// }
66-
// }
67-
// }
68-
// }.buttonStyle(.plain)
69-
// }
70-
// }
71-
// }
72-
// }.padding()
54+
VStack {
55+
if !otherAccounts.isEmpty {
56+
Text("Other Accounts")
57+
.font(.title3.bold())
58+
.frame(maxWidth: .infinity, alignment: .leading)
59+
LazyVGrid(columns: columns) {
60+
ForEach(otherAccounts) { account in
61+
NavigationLink {
62+
AccountView(account: account)
63+
} label: {
64+
GroupBox {
65+
HStack {
66+
if let domain = account.domain {
67+
FaviconView(website: domain)
68+
.frame(width: 40, height: 40)
69+
}
70+
VStack(alignment: .leading) {
71+
Text(account.domain ?? "Unknwon domain")
72+
.bold()
73+
.frame(maxWidth: .infinity, alignment: .leading)
74+
Text(account.username ?? "Unknown email or username")
75+
.foregroundColor(Color.secondary)
76+
}
77+
Spacer()
78+
Image(systemName: "chevron.right")
79+
.foregroundColor(.secondary)
80+
}
81+
}
82+
}.buttonStyle(.plain)
83+
}
84+
}
85+
}
86+
}
87+
.padding()
88+
.frame(maxWidth: 800)
7389
}
7490
#if os(iOS)
7591
.navigationTitle(account.domain?.capitalizingFirstLetter() ?? "")

Shared/Views/CardView/CardView.swift

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -11,9 +11,9 @@ struct CardView: View {
1111
// MARK: - Variables
1212
let card: Card
1313

14-
#if os(iOS)
15-
@ObservedObject var manager = MotionManager()
16-
#endif
14+
//#if os(iOS)
15+
// @ObservedObject var manager = MotionManager()
16+
//#endif
1717

1818
@State private var isShowingNumber: Bool = false
1919
@State private var decryptedNumber: String? = nil
@@ -130,7 +130,7 @@ struct CardView: View {
130130
.frame(width: 400)
131131
#else
132132
.frame(maxWidth: 400)
133-
.modifier(ParallaxMotionModifier(manager: manager, magnitude: 10))
133+
// .modifier(ParallaxMotionModifier(manager: manager, magnitude: 10))
134134
#endif
135135
}
136136
#if os(macOS)

Shared/Views/ContentView/ContentView+List.swift

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -55,6 +55,11 @@ extension ContentView {
5555
vaultToBeDeleted = vault
5656
shouldDeleteVault.toggle()
5757
}
58+
Button("Rename") {
59+
isCreatingNewVault = false
60+
newVaultName = vault.name ?? ""
61+
vaultToBeRenamed = vault
62+
}
5863
}
5964
.swipeActions {
6065
Button("Rename") {

Shared/Views/ContentView/ContentView.swift

Lines changed: 16 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -43,6 +43,8 @@ struct ContentView: View {
4343
@State var vaultToBeDeleted: Vault? = nil
4444
@State var vaultToBeRenamed: Vault? = nil
4545

46+
@State private var showSettings: Bool = false
47+
4648
// MARK: - View
4749
var body: some View {
4850
NavigationView {
@@ -56,11 +58,23 @@ struct ContentView: View {
5658
Label("Lock", systemImage: "lock.fill")
5759
}
5860
#if os(iOS)
59-
NavigationLink {
60-
SettingsView()
61+
Button {
62+
showSettings.toggle()
6163
} label: {
6264
Label("Settings", systemImage: "gearshape.fill")
6365
}
66+
.sheet(isPresented: $showSettings) {
67+
NavigationView {
68+
SettingsView()
69+
.toolbar {
70+
ToolbarItem(placement: .navigationBarTrailing) {
71+
Button("Done") {
72+
showSettings.toggle()
73+
}
74+
}
75+
}
76+
}
77+
}
6478
#endif
6579
}
6680
}

Shared/Views/ImportExport/ImportView/ImportView+Import.swift

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -55,7 +55,7 @@ extension ImportView {
5555

5656
let account = Account(context: viewContext)
5757
account.domain = domain
58-
account.url = url.absoluteString
58+
account.url = url.absoluteString.removeHTTP.removeWWW
5959

6060
account.username = importedAccount.username
6161
account.otpAuth = importedAccount.otpAuth

Shared/Views/Vault/VaultView/VaultView.swift

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -53,6 +53,7 @@ struct VaultView: View {
5353
viewModel.selectedItems.insert(selectedItem)
5454
}
5555
self._viewModel = StateObject(wrappedValue: viewModel)
56+
5657
}
5758

5859
// MARK: - View

0 commit comments

Comments
 (0)