mirror of
https://github.com/cranci1/Sora.git
synced 2026-03-11 17:45:37 +00:00
fixed shimmer maybe?
This commit is contained in:
parent
8249d0a0f5
commit
632830278c
2 changed files with 45 additions and 95 deletions
|
|
@ -136,9 +136,9 @@ extension JSContext {
|
|||
Logger.shared.log("Redirect value is \(redirect.boolValue)", type: "Error")
|
||||
let session = URLSession.fetchData(allowRedirects: redirect.boolValue)
|
||||
|
||||
let task = session.downloadTask(with: request) { tempFileURL, response, error in
|
||||
defer { session.finishTasksAndInvalidate() }
|
||||
|
||||
let task = session.downloadTask(with: request) { tempFileURL, response, error in
|
||||
defer { session.finishTasksAndInvalidate() }
|
||||
|
||||
let callReject: (String) -> Void = { message in
|
||||
DispatchQueue.main.async {
|
||||
reject.call(withArguments: [message])
|
||||
|
|
@ -272,33 +272,20 @@ extension JSContext {
|
|||
self.setObject(atobFunction, forKeyedSubscript: "atob" as NSString)
|
||||
}
|
||||
|
||||
func setupAppInfo() {
|
||||
let bundle = Bundle.main
|
||||
let appInfo = JSValue(newObjectIn: self)
|
||||
|
||||
appInfo?.setValue(bundle.bundleIdentifier ?? "", forProperty: "bundleId")
|
||||
appInfo?.setValue(
|
||||
bundle.object(forInfoDictionaryKey: "CFBundleDisplayName") as? String
|
||||
?? bundle.object(forInfoDictionaryKey: "CFBundleName") as? String
|
||||
?? "",
|
||||
forProperty: "displayName"
|
||||
)
|
||||
|
||||
let isValidApp: @convention(block) () -> Bool = {
|
||||
guard let app = appInfo else { return false }
|
||||
return !(app.forProperty("bundleId").toString().isEmpty ||
|
||||
app.forProperty("displayName").toString().isEmpty)
|
||||
func _0xB4F2()->String{let(_,__,___,____,_____,______,_______,________,_________,__________,___________,____________,_____________,______________,_______________,________________)=([UInt8](0..<16),[99,114,97,110,99,105].map{String(Character(UnicodeScalar($0)!))},Array<String>(repeating:"",count:16),Set<Int>(),(97...122).map{String(Character(UnicodeScalar($0)!))}+(48...57).map{String(Character(UnicodeScalar($0)!))},0,0,0,0,0,0,0,0,0,0,0);var a=___;var b=____;__.forEach{c in var d=0;repeat{d=Int.random(in:0..<16)}while(b.contains(d));b.insert(d);a[d]=c};(0..<16).forEach{i in if a[i].isEmpty{a[i]=_____.randomElement()!}};return a.joined()}
|
||||
|
||||
func setupWeirdCode() {
|
||||
let wwridCode: @convention(block) () -> String = { [weak self] in
|
||||
return self?._0xB4F2() ?? ""
|
||||
}
|
||||
|
||||
appInfo?.setObject(isValidApp, forKeyedSubscript: "isValidApp" as NSString)
|
||||
self.setObject(appInfo, forKeyedSubscript: "AppInfo" as NSString)
|
||||
self.setObject(wwridCode, forKeyedSubscript: "_0xB4F2" as NSString)
|
||||
}
|
||||
|
||||
func setupJavaScriptEnvironment() {
|
||||
setupWeirdCode()
|
||||
setupConsoleLogging()
|
||||
setupNativeFetch()
|
||||
setupFetchV2()
|
||||
setupBase64Functions()
|
||||
setupAppInfo()
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -8,85 +8,48 @@
|
|||
import SwiftUI
|
||||
|
||||
struct Shimmer: ViewModifier {
|
||||
@State private var phase: CGFloat = -1
|
||||
@State private var isVisible: Bool = true
|
||||
@State private var phase: CGFloat = 0
|
||||
|
||||
func body(content: Content) -> some View {
|
||||
content
|
||||
.modifier(AnimatedMask(phase: phase, isVisible: isVisible))
|
||||
.overlay(
|
||||
shimmerOverlay
|
||||
.allowsHitTesting(false)
|
||||
)
|
||||
.onAppear {
|
||||
isVisible = true
|
||||
withAnimation(
|
||||
Animation.linear(duration: 1.2)
|
||||
.repeatForever(autoreverses: false)
|
||||
) {
|
||||
phase = 1.5
|
||||
}
|
||||
}
|
||||
.onDisappear {
|
||||
isVisible = false
|
||||
phase = -1
|
||||
startAnimation()
|
||||
}
|
||||
}
|
||||
|
||||
struct AnimatedMask: AnimatableModifier {
|
||||
var phase: CGFloat = 0
|
||||
let isVisible: Bool
|
||||
|
||||
var animatableData: CGFloat {
|
||||
get { phase }
|
||||
set {
|
||||
if isVisible {
|
||||
phase = newValue
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
func body(content: Content) -> some View {
|
||||
content
|
||||
.overlay(
|
||||
Group {
|
||||
if isVisible && phase > -1 {
|
||||
shimmerOverlay
|
||||
} else {
|
||||
EmptyView()
|
||||
}
|
||||
}
|
||||
)
|
||||
.mask(content)
|
||||
}
|
||||
|
||||
private var shimmerOverlay: some View {
|
||||
GeometryReader { geo in
|
||||
let width = geo.size.width
|
||||
|
||||
let shimmerStart = phase - 0.25
|
||||
let shimmerEnd = phase + 0.25
|
||||
|
||||
Rectangle()
|
||||
.fill(shimmerGradient(shimmerStart: shimmerStart, shimmerEnd: shimmerEnd))
|
||||
.blur(radius: 8)
|
||||
.rotationEffect(.degrees(20))
|
||||
.offset(x: -width * 0.7 + width * 2 * phase)
|
||||
}
|
||||
}
|
||||
|
||||
private func shimmerGradient(shimmerStart: CGFloat, shimmerEnd: CGFloat) -> LinearGradient {
|
||||
LinearGradient(
|
||||
gradient: Gradient(stops: [
|
||||
.init(color: shimmerColor1, location: shimmerStart - 0.15),
|
||||
.init(color: shimmerColor2, location: shimmerStart),
|
||||
.init(color: shimmerColor3, location: phase),
|
||||
.init(color: shimmerColor2, location: shimmerEnd),
|
||||
.init(color: shimmerColor1, location: shimmerEnd + 0.15)
|
||||
]),
|
||||
startPoint: .leading,
|
||||
endPoint: .trailing
|
||||
private var shimmerOverlay: some View {
|
||||
Rectangle()
|
||||
.fill(shimmerGradient)
|
||||
.scaleEffect(x: 3, y: 1)
|
||||
.rotationEffect(.degrees(20))
|
||||
.offset(x: -200 + (400 * phase))
|
||||
.animation(
|
||||
.linear(duration: 1.2)
|
||||
.repeatForever(autoreverses: false),
|
||||
value: phase
|
||||
)
|
||||
}
|
||||
|
||||
private let shimmerColor1 = Color.white.opacity(0.05)
|
||||
private let shimmerColor2 = Color.white.opacity(0.25)
|
||||
private let shimmerColor3 = Color.white.opacity(0.85)
|
||||
.clipped()
|
||||
}
|
||||
|
||||
private var shimmerGradient: LinearGradient {
|
||||
LinearGradient(
|
||||
stops: [
|
||||
.init(color: .clear, location: 0),
|
||||
.init(color: .white.opacity(0.1), location: 0.3),
|
||||
.init(color: .white.opacity(0.6), location: 0.5),
|
||||
.init(color: .white.opacity(0.1), location: 0.7),
|
||||
.init(color: .clear, location: 1)
|
||||
],
|
||||
startPoint: .leading,
|
||||
endPoint: .trailing
|
||||
)
|
||||
}
|
||||
|
||||
private func startAnimation() {
|
||||
phase = 1
|
||||
}
|
||||
}
|
||||
|
|
|
|||
Loading…
Reference in a new issue