Skip to content

Commit

Permalink
Fix update view
Browse files Browse the repository at this point in the history
  • Loading branch information
ruixhuang committed Dec 4, 2023
1 parent 75350d0 commit a506973
Show file tree
Hide file tree
Showing 9 changed files with 53 additions and 25 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -17,13 +17,17 @@ public final class dydxUpdateWorker: BaseWorker {
public override func start() {
super.start()

AbacusStateManager.shared.state.environment
.compactMap { $0 }
.removeDuplicates()
.sink { environment in
Self.handle(environment: environment)
}
.store(in: &subscriptions)
Timer.scheduledTimer(withTimeInterval: 2.0, repeats: false) { [weak self] _ in
guard let self = self else { return }

AbacusStateManager.shared.state.environment
.compactMap { $0 }
.removeDuplicates()
.sink { environment in
Self.handle(environment: environment)
}
.store(in: &self.subscriptions)
}
}

public static func handle(environment: V4Environment?) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -37,24 +37,24 @@ private protocol dydxUpdateViewPresenterProtocol: HostedViewPresenterProtocol {
}

private class dydxUpdateViewPresenter: HostedViewPresenter<dydxUpdateViewModel>, dydxUpdateViewPresenterProtocol {
override init() {
super.init()

viewModel = dydxUpdateViewModel()
}

override func start() {
super.start()

if let ios = AbacusStateManager.shared.environment?.apps?.ios {
viewModel?.title = ios.title
viewModel?.text = ios.text
viewModel?.action = ios.action
viewModel?.title = DataLocalizer.localize(path: ios.title ?? "FORCED_UPDATE.TITLE")
viewModel?.text = DataLocalizer.localize(path: ios.text ?? "FORCED_UPDATE.TEXT")
viewModel?.action = DataLocalizer.localize(path: ios.action ?? "FORCED_UPDATE.ACTION")
viewModel?.updateTapped = { [weak self] in
if let url = URL(string: ios.url) {
Router.shared?.navigate(to: url, completion: nil)
}
}
}
}

override init() {
super.init()

viewModel = dydxUpdateViewModel()
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -324,7 +324,7 @@ public final class AbacusStateManager: NSObject {
if currentEnvironment == nil,
let stored = SettingsStore.shared?.value(forKey: Self.storeKey) as? String,
availableEnvironments.contains(where: { selection in
selection.type == stored
selection.type == stored
}) {
currentEnvironment = stored
} else {
Expand All @@ -349,6 +349,7 @@ public final class AbacusStateManager: NSObject {

extension AbacusStateManager: Abacus.StateNotificationProtocol {
public func environmentsChanged() {
_environment = asyncStateManager.environment
DispatchQueue.main.async { [weak self] in
self?.initializeCurrentEnvironment()
}
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
{
"images" : [
{
"filename" : "x.pdf",
"idiom" : "universal"
}
],
"info" : {
"author" : "xcode",
"version" : 1
}
}
Binary file not shown.
19 changes: 15 additions & 4 deletions dydx/dydxViews/dydxViews/_v4/Update/dydxUpdateView.swift
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,9 @@ public class dydxUpdateViewModel: PlatformViewModel {

public static var previewValue: dydxUpdateViewModel {
let vm = dydxUpdateViewModel()
vm.title = "Title"
vm.text = "text"
vm.action = "Action"
return vm
}

Expand All @@ -38,7 +41,9 @@ public class dydxUpdateViewModel: PlatformViewModel {
self.updateButton(parentStyle: parentStyle, styleKey: styleKey)
}
}
.frame(maxWidth: .infinity)
.padding(16)
.themeColor(background: .layer2)
)
}
}
Expand Down Expand Up @@ -79,10 +84,16 @@ public class dydxUpdateViewModel: PlatformViewModel {
}

private func logoImage(parentStyle: ThemeStyle, styleKey: String?) -> PlatformView {
PlatformIconViewModel(type: .asset(name: "brand", bundle: Bundle.particles.first),
clip: .noClip,
size: .init(width: 100, height: 100),
templateColor: nil)
let imageName: String
if currentThemeType == .light {
imageName = "brand_light"
} else {
imageName = "brand_dark"
}
return PlatformIconViewModel(type: .asset(name: imageName, bundle: Bundle.dydxView),
clip: .noClip,
size: .init(width: 100, height: 100),
templateColor: nil)
.createView(parentStyle: parentStyle, styleKey: styleKey)
}
}
Expand Down
8 changes: 4 additions & 4 deletions dydxV4/dydxV4.xcodeproj/project.pbxproj
Original file line number Diff line number Diff line change
Expand Up @@ -2082,7 +2082,7 @@
026FC3F22AFAD39800C52F20 /* Run Script (set_scheme.sh) */ = {
isa = PBXShellScriptBuildPhase;
alwaysOutOfDate = 1;
buildActionMask = 2147483647;
buildActionMask = 12;
files = (
);
inputFileListPaths = (
Expand All @@ -2096,12 +2096,12 @@
);
runOnlyForDeploymentPostprocessing = 0;
shellPath = /bin/sh;
shellScript = "# Type a script or drag a script file from your workspace to insert its path.\nSCRIPT_DIR=${PROJECT_DIR}/../scripts/\n\nOUTPUT=$(bash \"${SCRIPT_DIR}/set_scheme.sh\")\n\n# Echo the captured output (xcode does not automatically mirror it in build log)\necho \"$OUTPUT\"\n";
shellScript = "# Type a script or drag a script file from your workspace to insert its path.\nSCRIPT_DIR=${PROJECT_DIR}/../scripts/\n\nif [ $ENABLE_PREVIEWS == \"NO\" ]\nthen\n OUTPUT=$(bash \"${SCRIPT_DIR}/set_scheme.sh\")\n\n # Echo the captured output (xcode does not automatically mirror it in build log)\n echo \"$OUTPUT\"\nfi\n\n";
};
026FC4232AFAD3EB00C52F20 /* Run Script (unset_scheme.sh) */ = {
isa = PBXShellScriptBuildPhase;
alwaysOutOfDate = 1;
buildActionMask = 2147483647;
buildActionMask = 12;
files = (
);
inputFileListPaths = (
Expand All @@ -2115,7 +2115,7 @@
);
runOnlyForDeploymentPostprocessing = 0;
shellPath = /bin/sh;
shellScript = "# Type a script or drag a script file from your workspace to insert its path.\nSCRIPT_DIR=${PROJECT_DIR}/../scripts/\n\nOUTPUT=$(bash \"${SCRIPT_DIR}/unset_scheme.sh\")\n\n# Echo the captured output (xcode does not automatically mirror it in build log)\necho \"$OUTPUT\"\n\n";
shellScript = "# Type a script or drag a script file from your workspace to insert its path.\nSCRIPT_DIR=${PROJECT_DIR}/../scripts/\n\nif [ $ENABLE_PREVIEWS == \"NO\" ]\nthen\n OUTPUT=$(bash \"${SCRIPT_DIR}/unset_scheme.sh\")\n\n# Echo the captured output (xcode does not automatically mirror it in build log)\n echo \"$OUTPUT\"\nfi\n\n";
};
02C19F3D29DDD79300F77028 /* Run Script (Set Secrets) */ = {
isa = PBXShellScriptBuildPhase;
Expand Down

0 comments on commit a506973

Please sign in to comment.