Skip to content

Commit

Permalink
Merge pull request #15 from juandahurt/skeleton
Browse files Browse the repository at this point in the history
refactor: update some ui components
  • Loading branch information
juandahurt authored Jun 11, 2022
2 parents bde95a2 + b5fcefe commit 856ce1a
Show file tree
Hide file tree
Showing 5 changed files with 23 additions and 29 deletions.
11 changes: 11 additions & 0 deletions Sources/Purace/Styles/PuraceStyle.swift
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,17 @@ public struct PuraceStyle {
public static let G6 = SwiftUI.Color(hex: "C4CCD3") ?? .gray
public static let G7 = SwiftUI.Color(hex: "D7DCE1") ?? .gray
public static let G8 = SwiftUI.Color(hex: "DFE4E8") ?? .gray

public static let S1 = SwiftUI.Color(hex: "CECEC9") ?? .orange
public static let S2 = SwiftUI.Color(hex: "CFCCC8") ?? .orange
public static let S3 = SwiftUI.Color(hex: "E5DBCB") ?? .orange
public static let S4 = SwiftUI.Color(hex: "DACAB5") ?? .orange
public static let S5 = SwiftUI.Color(hex: "F1F2F4") ?? .orange
public static let S6 = SwiftUI.Color(hex: "D0CEC6") ?? .orange
public static let S7 = SwiftUI.Color(hex: "D4CAC6") ?? .orange
public static let S8 = SwiftUI.Color(hex: "C8D0CA") ?? .orange

public static let allSkeletons: [SwiftUI.Color] = [Color.S1, Color.S2, Color.S3, Color.S4, Color.S5, Color.S6, Color.S7, Color.S8]
}

public struct Font {
Expand Down
10 changes: 5 additions & 5 deletions Sources/Purace/Views/Basic/Button/PuraceButtonView.swift
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ public struct PuraceButtonView: View {
case .loud:
return .white
case .quiet:
return PuraceStyle.Color.B1
return PuraceStyle.Color.G1
case .custom(_, _, let textColor):
return textColor
}
Expand All @@ -38,9 +38,9 @@ public struct PuraceButtonView: View {
private func getBackgroundColor() -> Color {
switch type {
case .loud:
return PuraceStyle.Color.B2
return PuraceStyle.Color.G2
case .quiet:
return PuraceStyle.Color.B5
return PuraceStyle.Color.G6
case .custom(let backgroundColor, _, _):
return backgroundColor
}
Expand All @@ -49,9 +49,9 @@ public struct PuraceButtonView: View {
private func getOnPressedBackgroundColor() -> Color {
switch type {
case .loud:
return PuraceStyle.Color.B1
return PuraceStyle.Color.G1
case .quiet:
return PuraceStyle.Color.B4
return PuraceStyle.Color.G5
case .custom(_, let onPressedColor, _):
return onPressedColor
}
Expand Down
14 changes: 5 additions & 9 deletions Sources/Purace/Views/Basic/Image/PuraceImageView.swift
Original file line number Diff line number Diff line change
Expand Up @@ -10,25 +10,21 @@ import SwiftUI
import Kingfisher

public struct PuraceImageView: View {
let skeletonColor: Color
let url: URL?

public init(url: URL?) {
self.skeletonColor = PuraceStyle.Color.allSkeletons.randomElement()!
self.url = url
}

public var body: some View {
KFImage.url(url)
.resizable()
.fade(duration: 0.2)
.appendProcessor(DownsamplingImageProcessor(size: UIScreen.main.bounds.size))
.scaleFactor(UIScreen.main.scale)
.placeholder { _ in
GeometryReader { reader in
ZStack {
PuraceCircularLoaderView()
.foregroundColor(PuraceStyle.Color.G3)
.frame(width: reader.size.width * 0.1, height: reader.size.width * 0.1)
.position(x: reader.size.width / 2, y: reader.size.height / 2)
}
}
skeletonColor
}
}
}
14 changes: 0 additions & 14 deletions Sources/Purace/Views/Complex/Tab/PuraceTabItem.swift

This file was deleted.

3 changes: 2 additions & 1 deletion Sources/Purace/Views/Complex/Tab/PuraceTabView.swift
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@ public struct PuraceTabView<T: View>: View {
ForEach(0..<titles.count) { index in
PuraceTextView(titles[index], fontSize: 12, textColor: selectedIndex == index ? PuraceStyle.Color.N1 : PuraceStyle.Color.N4, weight: selectedIndex == index ? .medium : .regular)
.frame(width: size.width / CGFloat(titles.count))
.background(Color.gray.opacity(0.001))
.onTapGesture {
selectedIndex = index
updateIndicatorOffset(size: size)
Expand All @@ -38,7 +39,7 @@ public struct PuraceTabView<T: View>: View {
.frame(height: 1)
.opacity(0.1)
HStack {
PuraceStyle.Color.B2
PuraceStyle.Color.G2
.frame(width: size.width / CGFloat(titles.count), height: 3)
Spacer(minLength: 0)
}.offset(x: indicatorOffset, y: 0)
Expand Down

0 comments on commit 856ce1a

Please sign in to comment.