Skip to content

Commit

Permalink
Rename all ViewModels to Manager
Browse files Browse the repository at this point in the history
Not using traditional MVVM architecture so continuing to use ViewModel naming is confusing
  • Loading branch information
praveenperera committed Dec 9, 2024
1 parent 9db6721 commit bc99113
Show file tree
Hide file tree
Showing 60 changed files with 1,276 additions and 1,260 deletions.
2 changes: 1 addition & 1 deletion android/app/build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -72,7 +72,7 @@ dependencies {
implementation("org.jetbrains.kotlinx:kotlinx-coroutines-core:1.6.4")

// Jetpack compose / flow
implementation("androidx.lifecycle:lifecycle-viewmodel-compose:2.8.1")
implementation("androidx.lifecycle:lifecycle-Manager-compose:2.8.1")
implementation("androidx.lifecycle:lifecycle-runtime-ktx:2.4.0")
implementation("androidx.compose.runtime:runtime-livedata:1.0.5")

Expand Down
6 changes: 3 additions & 3 deletions android/app/src/main/java/org/bitcoinppl/cove/CoveApp.kt
Original file line number Diff line number Diff line change
Expand Up @@ -9,13 +9,13 @@ import androidx.compose.ui.graphics.Color
import androidx.compose.ui.tooling.preview.Preview
import androidx.compose.ui.unit.dp
import androidx.compose.ui.unit.sp
import com.example.cove.ViewModel
import com.example.cove.Manager
import com.example.cove.ui.theme.CoveTheme
import androidx.lifecycle.viewmodel.compose.viewModel
import androidx.lifecycle.Manager.compose.Manager
import org.bitcoinppl.cove.AutoComplete

@Composable
fun CoveApp(viewModel: ViewModel = viewModel()) {
fun CoveApp(Manager: Manager = Manager()) {
Box(
modifier = Modifier.fillMaxSize(),
contentAlignment = Alignment.Center
Expand Down
4 changes: 2 additions & 2 deletions android/app/src/main/java/org/bitcoinppl/cove/ViewModel.kt
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
package com.example.cove

import androidx.lifecycle.ViewModel
import androidx.lifecycle.Manager

class ViewModel : ViewModel()
class Manager : Manager()
198 changes: 99 additions & 99 deletions android/app/src/main/java/org/bitcoinppl/cove/cove.kt

Large diffs are not rendered by default.

24 changes: 12 additions & 12 deletions ios/Cove/MainViewModel.swift → ios/Cove/AppManager.swift
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
import Observation
import SwiftUI

@Observable class MainViewModel: FfiReconcile {
private let logger = Log(id: "MainViewModel")
@Observable class AppManager: FfiReconcile {
private let logger = Log(id: "AppManager")

var rust: FfiApp
var router: Router
Expand All @@ -25,7 +25,7 @@ import SwiftUI
var routeId = UUID()

@ObservationIgnored
weak var walletViewModel: WalletViewModel?
weak var walletManager: WalletManager?

public var selectedNetwork: Network {
rust.network()
Expand All @@ -43,7 +43,7 @@ import SwiftUI
}

public init() {
logger.debug("Initializing MainViewModel")
logger.debug("Initializing AppManager")

let rust = FfiApp()
let state = rust.state()
Expand All @@ -55,22 +55,22 @@ import SwiftUI
self.rust.listenForUpdates(updater: self)
}

public func getWalletViewModel(id: WalletId) throws -> WalletViewModel {
if let walletvm = walletViewModel, walletvm.id == id {
public func getWalletManager(id: WalletId) throws -> WalletManager {
if let walletvm = walletManager, walletvm.id == id {
logger.debug("found and using vm for \(id)")
return walletvm
}

logger.debug("did not find vm for \(id), creating new vm: \(walletViewModel?.id ?? "none")")
logger.debug("did not find vm for \(id), creating new vm: \(walletManager?.id ?? "none")")

let walletvm = try WalletViewModel(id: id)
walletViewModel = walletvm
let walletvm = try WalletManager(id: id)
walletManager = walletvm

return walletViewModel!
return walletManager!
}

public func updateWalletVm(_ vm: WalletViewModel) {
walletViewModel = vm
public func updateWalletVm(_ vm: WalletManager) {
walletManager = vm
}

var currentRoute: Route {
Expand Down
4 changes: 2 additions & 2 deletions ios/Cove/AsyncPreview.swift
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ struct AsyncPreview<Content: View>: View {
self.content = content
}

@State private var model = MainViewModel()
@State private var manager = AppManager()

var body: some View {
Group {
Expand All @@ -26,7 +26,7 @@ struct AsyncPreview<Content: View>: View {
}
}
.task {
await model.rust.initOnStart()
await manager.rust.initOnStart()
contentView = await content()
}
}
Expand Down
Loading

0 comments on commit bc99113

Please sign in to comment.