diff --git a/client/viewmodel/calculator/src/commonMain/kotlin/com/oztechan/ccc/client/viewmodel/calculator/CalculatorSEED.kt b/client/viewmodel/calculator/src/commonMain/kotlin/com/oztechan/ccc/client/viewmodel/calculator/CalculatorSEED.kt index 697df92e6c..9050aa4bd6 100644 --- a/client/viewmodel/calculator/src/commonMain/kotlin/com/oztechan/ccc/client/viewmodel/calculator/CalculatorSEED.kt +++ b/client/viewmodel/calculator/src/commonMain/kotlin/com/oztechan/ccc/client/viewmodel/calculator/CalculatorSEED.kt @@ -22,7 +22,6 @@ data class CalculatorState( ) : BaseState // Event -@Suppress("TooManyFunctions") interface CalculatorEvent : BaseEvent { fun onKeyPress(key: String) fun onItemClick(currency: Currency) @@ -33,7 +32,6 @@ interface CalculatorEvent : BaseEvent { fun onPasteToInput(text: String) fun onBarClick() fun onSettingsClicked() - fun onBaseChange(base: String) fun onSheetDismissed() } diff --git a/client/viewmodel/calculator/src/commonMain/kotlin/com/oztechan/ccc/client/viewmodel/calculator/CalculatorViewModel.kt b/client/viewmodel/calculator/src/commonMain/kotlin/com/oztechan/ccc/client/viewmodel/calculator/CalculatorViewModel.kt index 543e5034bf..32ec412d72 100644 --- a/client/viewmodel/calculator/src/commonMain/kotlin/com/oztechan/ccc/client/viewmodel/calculator/CalculatorViewModel.kt +++ b/client/viewmodel/calculator/src/commonMain/kotlin/com/oztechan/ccc/client/viewmodel/calculator/CalculatorViewModel.kt @@ -276,12 +276,6 @@ class CalculatorViewModel( sendEffect { CalculatorEffect.OpenSettings } } - override fun onBaseChange(base: String) { - Logger.d { "CalculatorViewModel onBaseChange $base" } - currentBaseChanged(base) - calculateOutput(state.value.input) - } - override fun onSheetDismissed() { Logger.d { "CalculatorViewModel onSheetDismissed" } calculationStorage.currentBase diff --git a/client/viewmodel/calculator/src/commonTest/kotlin/com/oztechan/ccc/client/viewmodel/calculator/CalculatorViewModelTest.kt b/client/viewmodel/calculator/src/commonTest/kotlin/com/oztechan/ccc/client/viewmodel/calculator/CalculatorViewModelTest.kt index 2c8b00dc69..fb518a0cfb 100644 --- a/client/viewmodel/calculator/src/commonTest/kotlin/com/oztechan/ccc/client/viewmodel/calculator/CalculatorViewModelTest.kt +++ b/client/viewmodel/calculator/src/commonTest/kotlin/com/oztechan/ccc/client/viewmodel/calculator/CalculatorViewModelTest.kt @@ -492,27 +492,6 @@ internal class CalculatorViewModelTest { } } - @Test - fun onBaseChanged() = runTest { - every { calculationStorage.currentBase } - .returns(currency1.code) - - everySuspend { backendApiService.getConversion(currency1.code) } - .returns(conversion) - - viewModel.state.onSubscription { - viewModel.event.onBaseChange(currency1.code) - }.firstOrNull().let { - assertNotNull(it) - assertNotNull(viewModel.data.conversion) - assertEquals(currency1.code, viewModel.data.conversion!!.base) - assertEquals(currency1.code, it.base) - - verify { analyticsManager.trackEvent(Event.BaseChange(Param.Base(currency1.code))) } - verify { analyticsManager.setUserProperty(UserProperty.BaseCurrency(currency1.code)) } - } - } - @Test fun onSheetDismissed() = runTest { // when base in state is equal to base in storage diff --git a/ios/CCC/UI/Calculator/CalculatorRootView.swift b/ios/CCC/UI/Calculator/CalculatorRootView.swift index 349e78c89b..854994a2c6 100644 --- a/ios/CCC/UI/Calculator/CalculatorRootView.swift +++ b/ios/CCC/UI/Calculator/CalculatorRootView.swift @@ -62,7 +62,7 @@ struct CalculatorRootView: View { text: String(\.choose_at_least_two_currency), buttonText: String(\.select), buttonAction: { - navigationStack.push(CurrenciesRootView(onBaseChange: { observable.event.onBaseChange(base: $0) })) + navigationStack.push(CurrenciesRootView()) } ) } @@ -80,12 +80,7 @@ struct CalculatorRootView: View { .sheet( isPresented: $isBarShown, onDismiss: { observable.event.onSheetDismissed() }, - content: { - SelectCurrencyRootView( - isBarShown: $isBarShown, - onCurrencySelected: { observable.event.onBaseChange(base: $0) } - ).environmentObject(navigationStack) - } + content: { SelectCurrencyRootView(isBarShown: $isBarShown).environmentObject(navigationStack) } ) .onAppear { observable.startObserving() @@ -109,7 +104,7 @@ struct CalculatorRootView: View { case is CalculatorEffect.OpenBar: isBarShown = true case is CalculatorEffect.OpenSettings: - navigationStack.push(SettingsRootView(onBaseChange: { observable.event.onBaseChange(base: $0) })) + navigationStack.push(SettingsRootView()) case is CalculatorEffect.ShowPasteRequest: isPasteRequestSnackShown.toggle() case let copyToClipboardEffect as CalculatorEffect.CopyToClipboard: diff --git a/ios/CCC/UI/Currencies/CurrenciesRootView.swift b/ios/CCC/UI/Currencies/CurrenciesRootView.swift index 71e6e6e156..f78f7e3bff 100644 --- a/ios/CCC/UI/Currencies/CurrenciesRootView.swift +++ b/ios/CCC/UI/Currencies/CurrenciesRootView.swift @@ -24,8 +24,6 @@ struct CurrenciesRootView: View { private let analyticsManager: AnalyticsManager = koin.get() - var onBaseChange: (String) -> Void - var body: some View { CurrenciesView( event: observable.event, @@ -50,8 +48,6 @@ struct CurrenciesRootView: View { navigationStack.push(CalculatorRootView()) case is CurrenciesEffect.Back: navigationStack.pop() - case let changeBaseEffect as CurrenciesEffect.ChangeBase: - onBaseChange(changeBaseEffect.newBase) default: logger.i(message: { "CurrenciesRootView unknown effect" }) } diff --git a/ios/CCC/UI/SelectCurrency/SelectCurrencyRootView.swift b/ios/CCC/UI/SelectCurrency/SelectCurrencyRootView.swift index 7523992979..c1bedc845f 100644 --- a/ios/CCC/UI/SelectCurrency/SelectCurrencyRootView.swift +++ b/ios/CCC/UI/SelectCurrency/SelectCurrencyRootView.swift @@ -24,8 +24,6 @@ struct SelectCurrencyRootView: View { private let analyticsManager: AnalyticsManager = koin.get() - var onCurrencySelected: (String) -> Void - var body: some View { SelectCurrencyView( event: observable.event, @@ -42,11 +40,10 @@ struct SelectCurrencyRootView: View { private func onEffect(effect: SelectCurrencyEffect) { logger.i(message: { "SelectCurrencyRootView onEffect \(effect.description)" }) switch effect { - case let currencyChangeEffect as SelectCurrencyEffect.CurrencyChange: - onCurrencySelected(currencyChangeEffect.newBase) + case is SelectCurrencyEffect.CurrencyChange: isBarShown = false case is SelectCurrencyEffect.OpenCurrencies: - navigationStack.push(CurrenciesRootView(onBaseChange: onCurrencySelected)) + navigationStack.push(CurrenciesRootView()) default: logger.i(message: { "SelectCurrencyRootView unknown effect" }) } diff --git a/ios/CCC/UI/Settings/SettingsRootView.swift b/ios/CCC/UI/Settings/SettingsRootView.swift index 42427f48a7..29199dd007 100644 --- a/ios/CCC/UI/Settings/SettingsRootView.swift +++ b/ios/CCC/UI/Settings/SettingsRootView.swift @@ -31,8 +31,6 @@ struct SettingsRootView: View { private let analyticsManager: AnalyticsManager = koin.get() - var onBaseChange: ((String) -> Void) - var body: some View { SettingsView( event: observable.event, @@ -74,7 +72,7 @@ struct SettingsRootView: View { case is SettingsEffect.Back: navigationStack.pop() case is SettingsEffect.OpenCurrencies: - navigationStack.push(CurrenciesRootView(onBaseChange: onBaseChange)) + navigationStack.push(CurrenciesRootView()) case is SettingsEffect.OpenWatchers: navigationStack.push(WatchersRootView()) case is SettingsEffect.FeedBack: diff --git a/ios/CCC/UI/Slides/BugReportSlideRootView.swift b/ios/CCC/UI/Slides/BugReportSlideRootView.swift index 593e24c6e9..e4ba1d9f65 100644 --- a/ios/CCC/UI/Slides/BugReportSlideRootView.swift +++ b/ios/CCC/UI/Slides/BugReportSlideRootView.swift @@ -24,7 +24,7 @@ struct BugReportSlideRootView: View { subTitle1: String(\.slide_bug_report_text_1), subTitle2: String(\.slide_bug_report_text_2), buttonText: String(\.got_it), - buttonAction: { navigationStack.push(CurrenciesRootView(onBaseChange: { _ in })) } + buttonAction: { navigationStack.push(CurrenciesRootView()) } ) .onAppear { analyticsManager.trackScreen(screenName: ScreenName.Slider(position: 2)) diff --git a/ios/CCC/UI/Watchers/WatchersRootView.swift b/ios/CCC/UI/Watchers/WatchersRootView.swift index 19eda04d7a..7514c9f49f 100644 --- a/ios/CCC/UI/Watchers/WatchersRootView.swift +++ b/ios/CCC/UI/Watchers/WatchersRootView.swift @@ -48,31 +48,11 @@ struct WatchersRootView: View { } .sheet( isPresented: $baseBarInfo.isShown, - content: { - SelectCurrencyRootView( - isBarShown: $baseBarInfo.isShown, - onCurrencySelected: { - observable.event.onBaseChanged( - watcher: baseBarInfo.watcher!, - newBase: $0 - ) - } - ).environmentObject(navigationStack) - } + content: { SelectCurrencyRootView(isBarShown: $baseBarInfo.isShown).environmentObject(navigationStack) } ) .sheet( isPresented: $targetBarInfo.isShown, - content: { - SelectCurrencyRootView( - isBarShown: $targetBarInfo.isShown, - onCurrencySelected: { - observable.event.onTargetChanged( - watcher: targetBarInfo.watcher!, - newTarget: $0 - ) - } - ).environmentObject(navigationStack) - } + content: { SelectCurrencyRootView(isBarShown: $targetBarInfo.isShown).environmentObject(navigationStack) } ) .onAppear { observable.startObserving()