Skip to content

Commit

Permalink
Turn all xcode Groups into folders
Browse files Browse the repository at this point in the history
  • Loading branch information
praveenperera committed Nov 28, 2024
1 parent db29b24 commit c28b8c8
Show file tree
Hide file tree
Showing 43 changed files with 8,731 additions and 6,699 deletions.
515 changes: 16 additions & 499 deletions ios/Cove.xcodeproj/project.pbxproj

Large diffs are not rendered by default.

14,644 changes: 8,569 additions & 6,075 deletions rust/ios/Cove/Cove.swift → ios/Cove/Cove.swift

Large diffs are not rendered by default.

File renamed without changes.
File renamed without changes.
78 changes: 78 additions & 0 deletions ios/Cove/Flows/SelectedWalletFlow/SelectedWalletContainer.swift
Original file line number Diff line number Diff line change
@@ -0,0 +1,78 @@
//
// SelectedWalletScreen.swift

Check warning on line 2 in ios/Cove/Flows/SelectedWalletFlow/SelectedWalletContainer.swift

View workflow job for this annotation

GitHub Actions / swiftformat

Ensure file name in header comment matches the actual file name. (headerFileName)
// Cove
//
// Created by Praveen Perera on 7/1/24.
//

import SwiftUI

struct SelectedWalletContainer: View {
@Environment(\.colorScheme) private var colorScheme
@Environment(MainViewModel.self) private var app
@Environment(\.navigate) private var navigate

let id: WalletId
@State private var model: WalletViewModel? = nil

func loadModel() {
if model != nil { return }

do {
Log.debug("Getting wallet \(id)")
model = try app.getWalletViewModel(id: id)
} catch {
Log.error("Something went very wrong: \(error)")
navigate(Route.listWallets)
}
}

var body: some View {
Group {
if let model {
SelectedWalletScreen(model: model)
.background(
model.loadState == .loading ?
LinearGradient(colors: [
.black.opacity(colorScheme == .dark ? 0.9 : 0),
.black.opacity(colorScheme == .dark ? 0.9 : 0),
], startPoint: .top, endPoint: .bottom) :
LinearGradient(stops: [
.init(color: .midnightBlue, location: 0.45),
.init(color: colorScheme == .dark ? .black.opacity(0.9) : .clear, location: 0.55),
], startPoint: .top, endPoint: .bottom)
)
.background(Color.white)

} else {
Text("Loading...")
}
}
.onAppear {
loadModel()
}
.task {
// small delay and then start scanning wallet
if let model {
do {
try? await Task.sleep(for: .milliseconds(400))
try await model.rust.startWalletScan()
} catch {
Log.error("Wallet Scan Failed \(error.localizedDescription)")
}
}
}
.onChange(of: model?.loadState) { _, loadState in
if case .loaded = loadState {
if let model {
app.updateWalletVm(model)
}
}
}
}
}

#Preview {
SelectedWalletContainer(id: WalletId())
.environment(MainViewModel())
}
Original file line number Diff line number Diff line change
Expand Up @@ -2,84 +2,19 @@
// SelectedWalletScreen.swift
// Cove
//
// Created by Praveen Perera on 7/1/24.
// Created by Praveen Perera on 11/28/24.
//

import ActivityIndicatorView
import SwiftUI

struct SelectedWalletScreen: View {
@Environment(\.colorScheme) private var colorScheme
@Environment(MainViewModel.self) private var app
@Environment(\.navigate) private var navigate

let id: WalletId
@State private var model: WalletViewModel? = nil

func loadModel() {
if model != nil { return }

do {
Log.debug("Getting wallet \(id)")
model = try app.getWalletViewModel(id: id)
} catch {
Log.error("Something went very wrong: \(error)")
navigate(Route.listWallets)
}
}

var body: some View {
Group {
if let model {
SelectedWalletScreenInner(model: model)
.background(
model.loadState == .loading ?
LinearGradient(colors: [
.black.opacity(colorScheme == .dark ? 0.9 : 0),
.black.opacity(colorScheme == .dark ? 0.9 : 0),
], startPoint: .top, endPoint: .bottom) :
LinearGradient(stops: [
.init(color: .midnightBlue, location: 0.45),
.init(color: colorScheme == .dark ? .black.opacity(0.9) : .clear, location: 0.55),
], startPoint: .top, endPoint: .bottom)
)
.background(Color.white)

} else {
Text("Loading...")
}
}
.onAppear {
loadModel()
}
.task {
// small delay and then start scanning wallet
if let model {
do {
try? await Task.sleep(for: .milliseconds(400))
try await model.rust.startWalletScan()
} catch {
Log.error("Wallet Scan Failed \(error.localizedDescription)")
}
}
}
.onChange(of: model?.loadState) { _, loadState in
if case .loaded = loadState {
if let model {
app.updateWalletVm(model)
}
}
}
}
}

private enum SheetState: Equatable {
case receive
case settings
case chooseAddressType([FoundAddress])
}

struct SelectedWalletScreenInner: View {
struct SelectedWalletScreen: View {
@Environment(\.safeAreaInsets) private var safeAreaInsets
@Environment(\.colorScheme) private var colorScheme
@Environment(MainViewModel.self) private var app
Expand Down Expand Up @@ -192,54 +127,65 @@ struct SelectedWalletScreenInner: View {
sheetState = TaggedItem(.receive)
}

var body: some View {
VStack {
ScrollView {
VStack(spacing: 0) {
WalletBalanceHeaderView(
balance: model.balance.confirmed,
metadata: model.walletMetadata,
updater: updater,
showReceiveSheet: showReceiveSheet
)
.clipped()
.ignoresSafeArea(.all)

VerifyReminder(
walletId: model.walletMetadata.id, isVerified: model.walletMetadata.verified
)
@ViewBuilder
var MainContent: some View {
VStack(spacing: 0) {
WalletBalanceHeaderView(
balance: model.balance.confirmed,
metadata: model.walletMetadata,
updater: updater,
showReceiveSheet: showReceiveSheet
)
.clipped()
.ignoresSafeArea(.all)

Transactions
.environment(model)
}
.toolbar {
ToolbarItem(placement: .principal) {
HStack(spacing: 10) {
if metadata.walletType == .cold {
BitcoinShieldIcon(width: 13, color: .white)
}
VerifyReminder(
walletId: model.walletMetadata.id, isVerified: model.walletMetadata.verified
)

Text(metadata.name)
.foregroundStyle(.white)
.font(.callout)
.fontWeight(.semibold)
}
Transactions
.environment(model)
}
.toolbar {
ToolbarItem(placement: .principal) {
HStack(spacing: 10) {
if metadata.walletType == .cold {
BitcoinShieldIcon(width: 13, color: .white)
}

ToolbarItem(placement: .navigationBarTrailing) {
Button(action: {
sheetState = TaggedItem(.settings)
}) {
Image(systemName: "gear")
.foregroundStyle(.white)
.font(.callout)
}
Text(metadata.name)
.foregroundStyle(.white)
.font(.callout)
.fontWeight(.semibold)
}
.contentShape(.contextMenuPreview, RoundedRectangle(cornerRadius: 8).inset(by: -8))
.contextMenu {
Button("Settings") {
sheetState = .init(.settings)
}
}
.toolbarColorScheme(.dark, for: .navigationBar)
.toolbarBackground(Color.midnightBlue.opacity(0.9), for: .navigationBar)
.toolbarBackground(shouldShowNavBar ? .visible : .hidden, for: .navigationBar)
.sheet(item: $sheetState, content: SheetContent)
}

ToolbarItemGroup(placement: .navigationBarTrailing) {
Button(action: {
app.sheetState = .init(.qr)
}) {
Image(systemName: "qrcode")
.foregroundStyle(.white)
.font(.callout)
}
}
}
.toolbarColorScheme(.dark, for: .navigationBar)
.toolbarBackground(Color.midnightBlue.opacity(0.9), for: .navigationBar)
.toolbarBackground(shouldShowNavBar ? .visible : .hidden, for: .navigationBar)
.sheet(item: $sheetState, content: SheetContent)
}

var body: some View {
VStack {
ScrollView {
MainContent
}
.refreshable {
try? await model.rust.forceWalletScan()
Expand Down Expand Up @@ -290,15 +236,10 @@ struct VerifyReminder: View {
}
}

#Preview("Loading") {
SelectedWalletScreen(id: WalletId())
.environment(MainViewModel())
}

#Preview("Loaded Wallet") {
#Preview {
AsyncPreview {
NavigationStack {
SelectedWalletScreenInner(model: WalletViewModel(preview: "preview_only"))
SelectedWalletScreen(model: WalletViewModel(preview: "preview_only"))
.environment(MainViewModel())
}
}
Expand Down
File renamed without changes.
Original file line number Diff line number Diff line change
Expand Up @@ -84,7 +84,7 @@ struct WalletBalanceHeaderView: View {
}

var body: some View {
VStack(spacing: 30) {
VStack(spacing: 26) {
VStack(spacing: 6) {
HStack {
Text(secondaryBalanceString)
Expand Down Expand Up @@ -161,7 +161,7 @@ struct WalletBalanceHeaderView: View {
}
}
.padding()
.padding(.vertical, 30)
.padding(.vertical, 26)
.padding(.top, safeAreaInsets.top + 25)
.background(
Image(.headerPattern)
Expand Down
File renamed without changes.
12 changes: 7 additions & 5 deletions ios/Cove/RouteView.swift
Original file line number Diff line number Diff line change
Expand Up @@ -17,10 +17,12 @@ struct RouteView: View {
.id(model.routeId)
} else {
VStack {
ActivityIndicatorView(isVisible: Binding.constant(true), type: .growingArc(.orange, lineWidth: 4))
.frame(width: 75, height: 75)
.padding(.bottom, 100)
.foregroundColor(.orange)
ActivityIndicatorView(
isVisible: Binding.constant(true), type: .growingArc(.orange, lineWidth: 4)
)
.frame(width: 75, height: 75)
.padding(.bottom, 100)
.foregroundColor(.orange)
}
}
}
Expand All @@ -44,7 +46,7 @@ func routeToView(model: MainViewModel, route: Route) -> some View {
case let .newWallet(route: route):
NewWalletContainer(route: route)
case let .selectedWallet(walletId):
SelectedWalletScreen(id: walletId)
SelectedWalletContainer(id: walletId)
case let .secretWords(id: walletId):
SecretWordsScreen(id: walletId)
case let .transactionDetails(id: id, details: details):
Expand Down
4 changes: 2 additions & 2 deletions scripts/build-ios.sh
Original file line number Diff line number Diff line change
Expand Up @@ -58,8 +58,8 @@ done
mv ./bindings/coveFFI.modulemap ./bindings/module.modulemap

# Move the Swift file to the project
rm ./ios/Cove/Cove.swift || true
mv ./bindings/cove.swift ./ios/Cove/Cove.swift
rm ../ios/Cove/Cove.swift || true
mv ./bindings/cove.swift ../ios/Cove/Cove.swift

# Recreate XCFramework
rm -rf "ios/Cove.xcframework" || true
Expand Down

0 comments on commit c28b8c8

Please sign in to comment.