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

Commit

Permalink
Improved performance and added 'other accounts' listing
Browse files Browse the repository at this point in the history
  • Loading branch information
EthanLipnik committed Sep 5, 2021
1 parent ecfc691 commit 6ce57e3
Show file tree
Hide file tree
Showing 6 changed files with 71 additions and 35 deletions.
72 changes: 44 additions & 28 deletions Shared/Views/AccountView/AccountView.swift
Original file line number Diff line number Diff line change
Expand Up @@ -38,38 +38,54 @@ struct AccountView: View {

// MARK: - View
var body: some View {
// let otherAccounts = accounts.filter({ $0.username != account.username }).map({ $0 })
let otherAccounts = accounts.filter({ $0.username != account.username }).map({ $0 })

let columns: [GridItem] = {
#if os(macOS)
return [.init(), .init()]
#else
return UIDevice.current.userInterfaceIdiom == .pad ? [.init(), .init()] : [.init()]
#endif
}()

ScrollView {
content

// VStack {
// if !otherAccounts.isEmpty {
// Text("Other Accounts")
// .frame(maxWidth: .infinity, alignment: .leading)
// LazyVStack {
// ForEach(otherAccounts) { account in
// NavigationLink {
// AccountView(account: account)
// } label: {
// GroupBox {
// HStack {
// FaviconView(website: "https://" + account.domain)
// .frame(width: 40, height: 40)
// VStack(alignment: .leading) {
// Text(account.domain)
// .bold()
// .frame(maxWidth: .infinity, alignment: .leading)
// Text(account.username)
// .foregroundColor(Color.secondary)
// }
// }
// }
// }.buttonStyle(.plain)
// }
// }
// }
// }.padding()
VStack {
if !otherAccounts.isEmpty {
Text("Other Accounts")
.font(.title3.bold())
.frame(maxWidth: .infinity, alignment: .leading)
LazyVGrid(columns: columns) {
ForEach(otherAccounts) { account in
NavigationLink {
AccountView(account: account)
} label: {
GroupBox {
HStack {
if let domain = account.domain {
FaviconView(website: domain)
.frame(width: 40, height: 40)
}
VStack(alignment: .leading) {
Text(account.domain ?? "Unknwon domain")
.bold()
.frame(maxWidth: .infinity, alignment: .leading)
Text(account.username ?? "Unknown email or username")
.foregroundColor(Color.secondary)
}
Spacer()
Image(systemName: "chevron.right")
.foregroundColor(.secondary)
}
}
}.buttonStyle(.plain)
}
}
}
}
.padding()
.frame(maxWidth: 800)
}
#if os(iOS)
.navigationTitle(account.domain?.capitalizingFirstLetter() ?? "")
Expand Down
8 changes: 4 additions & 4 deletions Shared/Views/CardView/CardView.swift
Original file line number Diff line number Diff line change
Expand Up @@ -11,9 +11,9 @@ struct CardView: View {
// MARK: - Variables
let card: Card

#if os(iOS)
@ObservedObject var manager = MotionManager()
#endif
//#if os(iOS)
// @ObservedObject var manager = MotionManager()
//#endif

@State private var isShowingNumber: Bool = false
@State private var decryptedNumber: String? = nil
Expand Down Expand Up @@ -130,7 +130,7 @@ struct CardView: View {
.frame(width: 400)
#else
.frame(maxWidth: 400)
.modifier(ParallaxMotionModifier(manager: manager, magnitude: 10))
// .modifier(ParallaxMotionModifier(manager: manager, magnitude: 10))
#endif
}
#if os(macOS)
Expand Down
5 changes: 5 additions & 0 deletions Shared/Views/ContentView/ContentView+List.swift
Original file line number Diff line number Diff line change
Expand Up @@ -55,6 +55,11 @@ extension ContentView {
vaultToBeDeleted = vault
shouldDeleteVault.toggle()
}
Button("Rename") {
isCreatingNewVault = false
newVaultName = vault.name ?? ""
vaultToBeRenamed = vault
}
}
.swipeActions {
Button("Rename") {
Expand Down
18 changes: 16 additions & 2 deletions Shared/Views/ContentView/ContentView.swift
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,8 @@ struct ContentView: View {
@State var vaultToBeDeleted: Vault? = nil
@State var vaultToBeRenamed: Vault? = nil

@State private var showSettings: Bool = false

// MARK: - View
var body: some View {
NavigationView {
Expand All @@ -56,11 +58,23 @@ struct ContentView: View {
Label("Lock", systemImage: "lock.fill")
}
#if os(iOS)
NavigationLink {
SettingsView()
Button {
showSettings.toggle()
} label: {
Label("Settings", systemImage: "gearshape.fill")
}
.sheet(isPresented: $showSettings) {
NavigationView {
SettingsView()
.toolbar {
ToolbarItem(placement: .navigationBarTrailing) {
Button("Done") {
showSettings.toggle()
}
}
}
}
}
#endif
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,7 @@ extension ImportView {

let account = Account(context: viewContext)
account.domain = domain
account.url = url.absoluteString
account.url = url.absoluteString.removeHTTP.removeWWW

account.username = importedAccount.username
account.otpAuth = importedAccount.otpAuth
Expand Down
1 change: 1 addition & 0 deletions Shared/Views/Vault/VaultView/VaultView.swift
Original file line number Diff line number Diff line change
Expand Up @@ -53,6 +53,7 @@ struct VaultView: View {
viewModel.selectedItems.insert(selectedItem)
}
self._viewModel = StateObject(wrappedValue: viewModel)

}

// MARK: - View
Expand Down

0 comments on commit 6ce57e3

Please sign in to comment.