Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Bump Abacus and apply various UI adjustment to simple trade #344

Merged
merged 19 commits into from
Jan 28, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 12 additions & 0 deletions PlatformUI/PlatformUI.xcodeproj/project.pbxproj
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@
0230377828C15C0E00412B72 /* PlatformViewModel.swift in Sources */ = {isa = PBXBuildFile; fileRef = 0230377728C15C0E00412B72 /* PlatformViewModel.swift */; };
023788F528B9924D00F212E1 /* PlatformButton.swift in Sources */ = {isa = PBXBuildFile; fileRef = 023788F428B9924D00F212E1 /* PlatformButton.swift */; };
0242E3E92A9B1AE1007605F9 /* Media.xcassets in Resources */ = {isa = PBXBuildFile; fileRef = 0242E3E82A9B1AE1007605F9 /* Media.xcassets */; };
024399142D45B0880073DCF3 /* ShimmeringView.swift in Sources */ = {isa = PBXBuildFile; fileRef = 024399132D45B0850073DCF3 /* ShimmeringView.swift */; };
0243A73729BB8DBB00A083FE /* PlatformListViewModel.swift in Sources */ = {isa = PBXBuildFile; fileRef = 0243A73629BB8DBB00A083FE /* PlatformListViewModel.swift */; };
0243A73E29BE2D7C00A083FE /* Divider.swift in Sources */ = {isa = PBXBuildFile; fileRef = 0243A73D29BE2D7C00A083FE /* Divider.swift */; };
024B794528B6A6A200F7C386 /* PlatformIcon.swift in Sources */ = {isa = PBXBuildFile; fileRef = 024B794428B6A6A200F7C386 /* PlatformIcon.swift */; };
Expand Down Expand Up @@ -119,6 +120,7 @@
0230377728C15C0E00412B72 /* PlatformViewModel.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = PlatformViewModel.swift; sourceTree = "<group>"; };
023788F428B9924D00F212E1 /* PlatformButton.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = PlatformButton.swift; sourceTree = "<group>"; };
0242E3E82A9B1AE1007605F9 /* Media.xcassets */ = {isa = PBXFileReference; lastKnownFileType = folder.assetcatalog; path = Media.xcassets; sourceTree = "<group>"; };
024399132D45B0850073DCF3 /* ShimmeringView.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = ShimmeringView.swift; sourceTree = "<group>"; };
0243A73629BB8DBB00A083FE /* PlatformListViewModel.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = PlatformListViewModel.swift; sourceTree = "<group>"; };
0243A73D29BE2D7C00A083FE /* Divider.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = Divider.swift; sourceTree = "<group>"; };
024B794428B6A6A200F7C386 /* PlatformIcon.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = PlatformIcon.swift; sourceTree = "<group>"; };
Expand Down Expand Up @@ -221,6 +223,14 @@
path = Buttons;
sourceTree = "<group>";
};
0243990E2D45B0770073DCF3 /* ShimmerView */ = {
isa = PBXGroup;
children = (
024399132D45B0850073DCF3 /* ShimmeringView.swift */,
);
path = ShimmerView;
sourceTree = "<group>";
};
0243A73C29BE2D6700A083FE /* Divider */ = {
isa = PBXGroup;
children = (
Expand Down Expand Up @@ -356,6 +366,7 @@
02E2C92D28A1C8A400F7C3BE /* PlatformUI */ = {
isa = PBXGroup;
children = (
0243990E2D45B0770073DCF3 /* ShimmerView */,
0207FCA42D2BCECD004C2C9F /* KeyboardObserving */,
02F16FDA28B491EE0085DC58 /* PlatformUI.swift */,
0230377728C15C0E00412B72 /* PlatformViewModel.swift */,
Expand Down Expand Up @@ -716,6 +727,7 @@
0230377828C15C0E00412B72 /* PlatformViewModel.swift in Sources */,
276581F82C139F36009E072A /* SingleAxisGeometryReader.swift in Sources */,
0278DD0E2A7C7A1400FE6ABE /* PlatformViewModel+Ext.swift in Sources */,
024399142D45B0880073DCF3 /* ShimmeringView.swift in Sources */,
0273A3332ACE06EE001B89F5 /* ThemeColorCache.swift in Sources */,
02ABDAF028D9150A00728C54 /* PlatformInput.swift in Sources */,
02DE89A628A2F10A00728FF3 /* SampleThemeInput.swift in Sources */,
Expand Down
29 changes: 23 additions & 6 deletions PlatformUI/PlatformUI/Components/Input/PlatformInput.swift
Original file line number Diff line number Diff line change
Expand Up @@ -27,10 +27,19 @@ private struct PlatformInputView: View {
}

var body: some View {
let alignment: Alignment
switch model.textAlignment {
case .leading:
alignment = .leading
case .trailing:
alignment = .trailing
default:
alignment = .center
}
return HStack(alignment: .center, spacing: 4) {
VStack(alignment: .leading, spacing: 4) {
header
ZStack(alignment: .leading) {
ZStack(alignment: alignment) {
if model.currentValue == nil || model.currentValue?.length == 0 {
placeholder
}
Expand Down Expand Up @@ -75,6 +84,7 @@ private struct PlatformInputView: View {
isFocused = editingChanged
model.onEditingChanged?(editingChanged)
})
.multilineTextAlignment(model.textAlignment)
.focused($isFocused)
.truncationMode(model.truncateMode)
.keyboardType(model.keyboardType)
Expand All @@ -86,6 +96,7 @@ private struct PlatformInputView: View {
private var placeholder: some View {
Text(model.placeHolder)
.themeColor(foreground: .textTertiary)
.opacity(0.3)
.themeStyle(style: parentStyle)
.lineLimit(1)
.minimumScaleFactor(0.5)
Expand All @@ -99,7 +110,6 @@ private struct PlatformInputView: View {
.themeColor(foreground: .textTertiary)
.themeFont(fontSize: .smaller)
model.labelAccessory
Spacer()
}.wrappedInAnyView()
}
}
Expand All @@ -118,6 +128,7 @@ public class PlatformInputModel: PlatformViewModel {
@Published public var focusedOnAppear: Bool = false
@Published public var isFocused: Bool = false
@Published public var twoWayBinding: Bool = false
@Published public var textAlignment: TextAlignment = .leading

public init(label: String? = nil,
labelAccessory: AnyView? = nil,
Expand All @@ -131,7 +142,8 @@ public class PlatformInputModel: PlatformViewModel {
truncateMode: Text.TruncationMode = .tail,
focusedOnAppear: Bool = false,
isFocused: Bool = false,
twoWayBinding: Bool = false) {
twoWayBinding: Bool = false,
textAlignment: TextAlignment = .leading) {
self.label = label
self.labelAccessory = labelAccessory
self.value = value
Expand All @@ -145,6 +157,7 @@ public class PlatformInputModel: PlatformViewModel {
self.focusedOnAppear = focusedOnAppear
self.isFocused = isFocused
self.twoWayBinding = twoWayBinding
self.textAlignment = textAlignment
}

public static var previewValue: PlatformInputModel = {
Expand Down Expand Up @@ -296,7 +309,8 @@ open class PlatformTextInputViewModel: PlatformValueInputViewModel {
private let truncateMode: Text.TruncationMode
private let focusedOnAppear: Bool
private let twoWayBinding: Bool

private let textAlignment: TextAlignment

@Published public var isFocused: Bool = false

public init(label: String? = nil,
Expand All @@ -309,11 +323,13 @@ open class PlatformTextInputViewModel: PlatformValueInputViewModel {
onEdited: ((String?) -> Void)? = nil,
truncateMode: Text.TruncationMode = .middle,
focusedOnAppear: Bool = false,
twoWayBinding: Bool = false) {
twoWayBinding: Bool = false,
textAlignment: TextAlignment = .leading) {
self.inputType = inputType
self.truncateMode = truncateMode
self.focusedOnAppear = focusedOnAppear
self.twoWayBinding = twoWayBinding
self.textAlignment = textAlignment
super.init(label: label, labelAccessory: labelAccessory, valueAccessoryView: valueAccessoryView, onEdited: onEdited)
self.value = value
input = value ?? ""
Expand All @@ -339,7 +355,8 @@ open class PlatformTextInputViewModel: PlatformValueInputViewModel {
truncateMode: truncateMode,
focusedOnAppear: focusedOnAppear,
isFocused: isFocused,
twoWayBinding: twoWayBinding
twoWayBinding: twoWayBinding,
textAlignment: textAlignment
)

return AnyView(PlatformInputView(model: model,
Expand Down
74 changes: 74 additions & 0 deletions PlatformUI/PlatformUI/ShimmerView/ShimmeringView.swift
Original file line number Diff line number Diff line change
@@ -0,0 +1,74 @@
//
// ShimmeringView.swift
// PlatformUI
//
// Created by Rui Huang on 26/01/2025.
//

import SwiftUI

public struct ShimmerConfiguration {
public let gradient: Gradient
public let initialLocation: (start: UnitPoint, end: UnitPoint)
public let finalLocation: (start: UnitPoint, end: UnitPoint)
public let duration: TimeInterval
public let opacity: Double
public static let `default` = ShimmerConfiguration(
gradient: Gradient(stops: [
.init(color: .black, location: 0),
.init(color: .white, location: 0.3),
.init(color: .white, location: 0.7),
.init(color: .black, location: 1),
]),
initialLocation: (start: UnitPoint(x: -1, y: 0.5), end: .leading),
finalLocation: (start: .trailing, end: UnitPoint(x: 2, y: 0.5)),
duration: 2,
opacity: 0.6
)
}

struct ShimmeringView<Content: View>: View {
private let content: () -> Content
private let configuration: ShimmerConfiguration
@State private var startPoint: UnitPoint
@State private var endPoint: UnitPoint
init(configuration: ShimmerConfiguration, @ViewBuilder content: @escaping () -> Content) {
self.configuration = configuration
self.content = content
_startPoint = .init(wrappedValue: configuration.initialLocation.start)
_endPoint = .init(wrappedValue: configuration.initialLocation.end)
}
var body: some View {
ZStack {
content()
LinearGradient(
gradient: configuration.gradient,
startPoint: startPoint,
endPoint: endPoint
)
.opacity(configuration.opacity)
.blendMode(.screen)
.onAppear {
withAnimation(Animation.linear(duration: configuration.duration).repeatForever(autoreverses: false)) {
startPoint = configuration.finalLocation.start
endPoint = configuration.finalLocation.end
}
}
}
.edgesIgnoringSafeArea(.all)
}
}

public struct ShimmerModifier: ViewModifier {
let configuration: ShimmerConfiguration
public func body(content: Content) -> some View {
ShimmeringView(configuration: configuration) { content }
}
}


public extension View {
func shimmer(configuration: ShimmerConfiguration = .default) -> some View {
modifier(ShimmerModifier(configuration: configuration))
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -93,6 +93,7 @@ public final class StatsigFeatureFlagsProvider: NSObject, FeatureFlagsProtocol {
Console.shared.log("analytics log | Statsig feature flags finished initial fetch with error: \(error)")
return
}

self?.initializationState = .initializedRemoteLoaded
// intentionally not calling completion here since we do not want ff init to be blocking startup
// this may change if we need FF pre-launch
Expand Down
Loading