-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Bump Abacus and apply various UI adjustment to simple trade (#344)
* Help and Welcome * FTU * Analytic events * center input and add splash * Bordered token view, center size input * market list loading view * Portfolio loading view * Cleanups * User property * Bump Abacus * Dismiss in app alert after 3 seconds * Clean up * Clean up * Clean up * Bump version
- Loading branch information
Showing
221 changed files
with
21,206 additions
and
20,226 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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)) | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.