Skip to content

Commit

Permalink
Merge branch 'release/2.2.10' of github.com:Outblock/FRW-iOS into rel…
Browse files Browse the repository at this point in the history
…ease/2.2.10
  • Loading branch information
zhouxl committed Nov 4, 2024
2 parents df65ad1 + 36508af commit 48b9430
Show file tree
Hide file tree
Showing 7 changed files with 509 additions and 0 deletions.
38 changes: 38 additions & 0 deletions FRW.xcodeproj/project.pbxproj
Original file line number Diff line number Diff line change
Expand Up @@ -883,6 +883,16 @@
15DE22F1277F133B00B5EE03 /* SkeletonUI in Frameworks */ = {isa = PBXBuildFile; productRef = 15DE22F0277F133B00B5EE03 /* SkeletonUI */; };
15DE22FD27801ADE00B5EE03 /* GoogleOAuth2.plist in Resources */ = {isa = PBXBuildFile; fileRef = 15DE22FC27801ADE00B5EE03 /* GoogleOAuth2.plist */; };
15DE23012780208300B5EE03 /* RestoreWalletViewModel.swift in Sources */ = {isa = PBXBuildFile; fileRef = 15DE22FF2780208300B5EE03 /* RestoreWalletViewModel.swift */; };
15DFD32C2CD4576A004B0DB8 /* FluidGradientView.swift in Sources */ = {isa = PBXBuildFile; fileRef = 15DFD3292CD4576A004B0DB8 /* FluidGradientView.swift */; };
15DFD32D2CD4576A004B0DB8 /* FluidGradient.swift in Sources */ = {isa = PBXBuildFile; fileRef = 15DFD3282CD4576A004B0DB8 /* FluidGradient.swift */; };
15DFD32E2CD4576A004B0DB8 /* CGPoint+Extensions.swift in Sources */ = {isa = PBXBuildFile; fileRef = 15DFD3272CD4576A004B0DB8 /* CGPoint+Extensions.swift */; };
15DFD32F2CD4576A004B0DB8 /* BlobLayer.swift in Sources */ = {isa = PBXBuildFile; fileRef = 15DFD3262CD4576A004B0DB8 /* BlobLayer.swift */; };
15DFD3302CD4576A004B0DB8 /* ResizableLayer.swift in Sources */ = {isa = PBXBuildFile; fileRef = 15DFD32A2CD4576A004B0DB8 /* ResizableLayer.swift */; };
15DFD3312CD4576A004B0DB8 /* FluidGradientView.swift in Sources */ = {isa = PBXBuildFile; fileRef = 15DFD3292CD4576A004B0DB8 /* FluidGradientView.swift */; };
15DFD3322CD4576A004B0DB8 /* FluidGradient.swift in Sources */ = {isa = PBXBuildFile; fileRef = 15DFD3282CD4576A004B0DB8 /* FluidGradient.swift */; };
15DFD3332CD4576A004B0DB8 /* CGPoint+Extensions.swift in Sources */ = {isa = PBXBuildFile; fileRef = 15DFD3272CD4576A004B0DB8 /* CGPoint+Extensions.swift */; };
15DFD3342CD4576A004B0DB8 /* BlobLayer.swift in Sources */ = {isa = PBXBuildFile; fileRef = 15DFD3262CD4576A004B0DB8 /* BlobLayer.swift */; };
15DFD3352CD4576A004B0DB8 /* ResizableLayer.swift in Sources */ = {isa = PBXBuildFile; fileRef = 15DFD32A2CD4576A004B0DB8 /* ResizableLayer.swift */; };
15ECAE3928C4FCE600B79453 /* WalletConnectView.swift in Sources */ = {isa = PBXBuildFile; fileRef = 15CC8A6B28C4F817001D2696 /* WalletConnectView.swift */; };
15ECAE3A28C4FCE700B79453 /* WalletConnectView.swift in Sources */ = {isa = PBXBuildFile; fileRef = 15CC8A6B28C4F817001D2696 /* WalletConnectView.swift */; };
15ECAE3B28C4FCEB00B79453 /* WalletConnectViewModel.swift in Sources */ = {isa = PBXBuildFile; fileRef = 15CC8A6C28C4F836001D2696 /* WalletConnectViewModel.swift */; };
Expand Down Expand Up @@ -2299,6 +2309,11 @@
15DE22EA277F0B0C00B5EE03 /* Shimmer.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = Shimmer.swift; sourceTree = "<group>"; };
15DE22FC27801ADE00B5EE03 /* GoogleOAuth2.plist */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text.plist.xml; path = GoogleOAuth2.plist; sourceTree = "<group>"; };
15DE22FF2780208300B5EE03 /* RestoreWalletViewModel.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = RestoreWalletViewModel.swift; sourceTree = "<group>"; };
15DFD3262CD4576A004B0DB8 /* BlobLayer.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = BlobLayer.swift; sourceTree = "<group>"; };
15DFD3272CD4576A004B0DB8 /* CGPoint+Extensions.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = "CGPoint+Extensions.swift"; sourceTree = "<group>"; };
15DFD3282CD4576A004B0DB8 /* FluidGradient.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = FluidGradient.swift; sourceTree = "<group>"; };
15DFD3292CD4576A004B0DB8 /* FluidGradientView.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = FluidGradientView.swift; sourceTree = "<group>"; };
15DFD32A2CD4576A004B0DB8 /* ResizableLayer.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = ResizableLayer.swift; sourceTree = "<group>"; };
15EC9DF1274FD1FD00F70CD9 /* FRW_App.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = FRW_App.swift; sourceTree = "<group>"; };
15EC9DF5274FD1FD00F70CD9 /* Assets.xcassets */ = {isa = PBXFileReference; lastKnownFileType = folder.assetcatalog; path = Assets.xcassets; sourceTree = "<group>"; };
15EC9DF8274FD1FD00F70CD9 /* Preview Assets.xcassets */ = {isa = PBXFileReference; lastKnownFileType = folder.assetcatalog; path = "Preview Assets.xcassets"; sourceTree = "<group>"; };
Expand Down Expand Up @@ -4624,6 +4639,18 @@
path = ViewModel;
sourceTree = "<group>";
};
15DFD32B2CD4576A004B0DB8 /* FluidGradient */ = {
isa = PBXGroup;
children = (
15DFD3262CD4576A004B0DB8 /* BlobLayer.swift */,
15DFD3272CD4576A004B0DB8 /* CGPoint+Extensions.swift */,
15DFD3282CD4576A004B0DB8 /* FluidGradient.swift */,
15DFD3292CD4576A004B0DB8 /* FluidGradientView.swift */,
15DFD32A2CD4576A004B0DB8 /* ResizableLayer.swift */,
);
path = FluidGradient;
sourceTree = "<group>";
};
15EC9DE5274FD1FC00F70CD9 = {
isa = PBXGroup;
children = (
Expand Down Expand Up @@ -5782,6 +5809,7 @@
6ABAE52D2836297C00C97AE2 /* ThirdParty */ = {
isa = PBXGroup;
children = (
15DFD32B2CD4576A004B0DB8 /* FluidGradient */,
4E3138052C658FB2003A73E5 /* DebugViewer */,
4E5646532C0606A300890E61 /* PopupView */,
4ED9C5BE2C0487D1004276D1 /* FloatingButton */,
Expand Down Expand Up @@ -6699,6 +6727,11 @@
15DC20CD27819C56000B187A /* VNavigationLink.swift in Sources */,
15ADAE2B28F51EBB0014B722 /* SymmetricEncryption.swift in Sources */,
4E31380B2C658FB2003A73E5 /* CappedCollection.swift in Sources */,
15DFD3312CD4576A004B0DB8 /* FluidGradientView.swift in Sources */,
15DFD3322CD4576A004B0DB8 /* FluidGradient.swift in Sources */,
15DFD3332CD4576A004B0DB8 /* CGPoint+Extensions.swift in Sources */,
15DFD3342CD4576A004B0DB8 /* BlobLayer.swift in Sources */,
15DFD3352CD4576A004B0DB8 /* ResizableLayer.swift in Sources */,
4E09A1F22CC79A5C0099606E /* EventTrackName.swift in Sources */,
15DC20DD27819C56000B187A /* VPrimaryButton.swift in Sources */,
15DC21AD27819C56000B187A /* VBaseTextFieldModel.swift in Sources */,
Expand Down Expand Up @@ -7489,6 +7522,11 @@
15C58AB92868A4EE00BD4FC6 /* VNavigationLink.swift in Sources */,
15ADAE2A28F51EBB0014B722 /* SymmetricEncryption.swift in Sources */,
4E31380A2C658FB2003A73E5 /* CappedCollection.swift in Sources */,
15DFD32C2CD4576A004B0DB8 /* FluidGradientView.swift in Sources */,
15DFD32D2CD4576A004B0DB8 /* FluidGradient.swift in Sources */,
15DFD32E2CD4576A004B0DB8 /* CGPoint+Extensions.swift in Sources */,
15DFD32F2CD4576A004B0DB8 /* BlobLayer.swift in Sources */,
15DFD3302CD4576A004B0DB8 /* ResizableLayer.swift in Sources */,
4E09A1F32CC79A5C0099606E /* EventTrackName.swift in Sources */,
15C58ABA2868A4EE00BD4FC6 /* VPrimaryButton.swift in Sources */,
15C58ABB2868A4EE00BD4FC6 /* VBaseTextFieldModel.swift in Sources */,
Expand Down
13 changes: 13 additions & 0 deletions FRW/Modules/Wallet/Card/CardBackground.swift
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@ enum CardBackground: CaseIterable {
.fluid,
.matrix,
.fade(imageIndex: 0),
.fluidGradient
]

static var imageCases: [CardBackground] = [
Expand All @@ -33,6 +34,7 @@ enum CardBackground: CaseIterable {
.fluid,
.matrix,
.color(color: UIColor.LL.Primary.salmonPrimary),
.fluidGradient,
.fade(imageIndex: 0),
]

Expand All @@ -41,6 +43,7 @@ enum CardBackground: CaseIterable {
case fade(imageIndex: Int)
case fluid
case matrix
case fluidGradient

@ViewBuilder
func renderView() -> some View {
Expand All @@ -64,6 +67,10 @@ enum CardBackground: CaseIterable {
(imageList[safe: imageIndex] ?? imageList[0])
.resizable()
.aspectRatio(contentMode: .fill)
case .fluidGradient:
FluidGradient(blobs: [.green, .blue, .red, .pink, .purple, .indigo],
highlights: [.green, .yellow, .orange, .blue, .pink, .indigo],
speed: 0.8)
}
}

Expand Down Expand Up @@ -115,6 +122,8 @@ enum CardBackground: CaseIterable {
return identify
case .matrix:
return identify
case .fluidGradient:
return identify
}
}

Expand All @@ -130,6 +139,8 @@ enum CardBackground: CaseIterable {
return "fluid"
case .matrix:
return "matrix"
case .fluidGradient:
return "fluidGradient"
}
}

Expand Down Expand Up @@ -173,6 +184,8 @@ enum CardBackground: CaseIterable {
return
}
self = .image(imageIndex: index)
case CardBackground.fluidGradient.identify:
self = .fluidGradient
default:
self = .fade(imageIndex: 0)
}
Expand Down
111 changes: 111 additions & 0 deletions FRW/Tools/ThirdParty/FluidGradient/BlobLayer.swift
Original file line number Diff line number Diff line change
@@ -0,0 +1,111 @@
//
// BlobLayer.swift
// BlobLayer
//
// Created by João Gabriel Pozzobon dos Santos on 04/10/22.
//

import SwiftUI

/// A CALayer that draws a single blob on the screen
public class BlobLayer: CAGradientLayer {
init(color: Color) {
super.init()

self.type = .radial
#if os(OSX)
autoresizingMask = [.layerWidthSizable, .layerHeightSizable]
#endif

// Set color
set(color: color)

// Center point
let position = newPosition()
self.startPoint = position

// Radius
let radius = newRadius()
self.endPoint = position.displace(by: radius)
}

/// Generate a random point on the canvas
func newPosition() -> CGPoint {
return CGPoint(x: CGFloat.random(in: 0.0...1.0),
y: CGFloat.random(in: 0.0...1.0)).capped()
}

/// Generate a random radius for the blob
func newRadius() -> CGPoint {
let size = CGFloat.random(in: 0.15...0.75)
let viewRatio = frame.width/frame.height
let safeRatio = max(viewRatio.isNaN ? 1 : viewRatio, 1)
let ratio = safeRatio*CGFloat.random(in: 0.25...1.75)
return CGPoint(x: size,
y: size*ratio)
}

/// Animate the blob to a random point and size on screen at set speed
func animate(speed: CGFloat) {
guard speed > 0 else { return }

self.removeAllAnimations()
let currentLayer = self.presentation() ?? self

let animation = CASpringAnimation()
animation.mass = 10/speed
animation.damping = 50
animation.duration = 1/speed

animation.isRemovedOnCompletion = false
animation.fillMode = CAMediaTimingFillMode.forwards

let position = newPosition()
let radius = newRadius()

// Center point
let start = animation.copy() as! CASpringAnimation
start.keyPath = "startPoint"
start.fromValue = currentLayer.startPoint
start.toValue = position

// Radius
let end = animation.copy() as! CASpringAnimation
end.keyPath = "endPoint"
end.fromValue = currentLayer.endPoint
end.toValue = position.displace(by: radius)

self.startPoint = position
self.endPoint = position.displace(by: radius)

// Opacity
let value = Float.random(in: 0.5...1)
let opacity = animation.copy() as! CASpringAnimation
opacity.fromValue = self.opacity
opacity.toValue = value

self.opacity = value

self.add(opacity, forKey: "opacity")
self.add(start, forKey: "startPoint")
self.add(end, forKey: "endPoint")
}

/// Set the color of the blob
func set(color: Color) {
// Converted to the system color so that cgColor isn't nil
self.colors = [SystemColor(color).cgColor,
SystemColor(color).cgColor,
SystemColor(color.opacity(0.0)).cgColor]
self.locations = [0.0, 0.9, 1.0]
}

required init?(coder: NSCoder) {
fatalError("init(coder:) has not been implemented")
}

// Required by the framework
public override init(layer: Any) {
super.init(layer: layer)
}
}
22 changes: 22 additions & 0 deletions FRW/Tools/ThirdParty/FluidGradient/CGPoint+Extensions.swift
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
//
// CGPoint+Extensions.swift
//
//
// Created by João Gabriel Pozzobon dos Santos on 03/10/22.
//

import CoreGraphics

extension CGPoint {
/// Build a point from an origin and a displacement
func displace(by point: CGPoint = .init(x: 0.0, y: 0.0)) -> CGPoint {
return CGPoint(x: self.x+point.x,
y: self.y+point.y)
}

/// Caps the point to the unit space
func capped() -> CGPoint {
return CGPoint(x: max(min(x, 1), 0),
y: max(min(y, 1), 0))
}
}
Loading

0 comments on commit 48b9430

Please sign in to comment.