Skip to content

Commit

Permalink
some UI updates
Browse files Browse the repository at this point in the history
  • Loading branch information
0xChqrles committed Jun 24, 2024
1 parent b9ea19f commit 633fd91
Show file tree
Hide file tree
Showing 23 changed files with 240 additions and 176 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -5,9 +5,9 @@
"color-space" : "srgb",
"components" : {
"alpha" : "1.000",
"blue" : "0x1D",
"green" : "0x18",
"red" : "0x17"
"blue" : "0x22",
"green" : "0x1D",
"red" : "0x1C"
}
},
"idiom" : "universal"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
"color" : {
"color-space" : "srgb",
"components" : {
"alpha" : "0.500",
"alpha" : "1.000",
"blue" : "0xD5",
"green" : "0xA0",
"red" : "0x26"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
"color" : {
"color-space" : "srgb",
"components" : {
"alpha" : "0.500",
"alpha" : "1.000",
"blue" : "0x26",
"green" : "0xD5",
"red" : "0x7E"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
"color" : {
"color-space" : "srgb",
"components" : {
"alpha" : "0.500",
"alpha" : "1.000",
"blue" : "0x80",
"green" : "0xD5",
"red" : "0x26"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
"color" : {
"color-space" : "srgb",
"components" : {
"alpha" : "0.500",
"alpha" : "1.000",
"blue" : "0x26",
"green" : "0xA3",
"red" : "0xD5"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
"color" : {
"color-space" : "srgb",
"components" : {
"alpha" : "0.500",
"alpha" : "1.000",
"blue" : "0xB8",
"green" : "0x26",
"red" : "0xD5"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
"color" : {
"color-space" : "srgb",
"components" : {
"alpha" : "0.500",
"alpha" : "1.000",
"blue" : "0xD5",
"green" : "0x26",
"red" : "0x53"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,17 +21,17 @@ struct Avatar: View {

init(
salt: String? = nil,
name: String = Self.defaultName,
name: String? = nil,
size: CGFloat = Self.defaultSize
) {
self.name = name
self.name = name ?? Self.defaultName
self.size = size
self.salt = salt
}

init(
salt: String? = nil,
name: String = Self.defaultName,
name: String? = nil,
size: CGFloat = Self.defaultSize,
url: String? = nil
) {
Expand All @@ -41,7 +41,7 @@ struct Avatar: View {

init(
salt: String? = nil,
name: String = Self.defaultName,
name: String? = nil,
size: CGFloat = Self.defaultSize,
data: Data? = nil
) {
Expand All @@ -57,7 +57,7 @@ struct Avatar: View {
image
.resizable()
.aspectRatio(contentMode: .fill)
.frame(width: 42, height: 42)
.frame(width: self.size, height: self.size)
.scaledToFit()
},
placeholder: {
Expand All @@ -72,11 +72,11 @@ struct Avatar: View {
Image(uiImage: uiImage)
.resizable()
.aspectRatio(contentMode: .fill)
.frame(width: size, height: size)
.frame(width: self.size, height: self.size)
.scaledToFit()
.clipShape(Circle())
} else {
NoAvatar(salt: self.salt, name: self.name)
NoAvatar(salt: self.salt, name: self.name, size: self.size)
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -16,25 +16,25 @@ enum NoAvatarSalt: Int, CaseIterable {
case s5 = 4
case s6 = 5

var colors: (Color, Color) {
var gradient: Gradient {
switch self {
case .s1:
return (.vPurple, .vPurpleA50)
return Gradient(colors: [.vPurple, .vPurpleDarker])

case .s2:
return (.vGreen, .vGreenA50)
return Gradient(colors: [.vGreen, .vGreenDarker])

case .s3:
return (.vLime, .vLimeA50)
return Gradient(colors: [.vLime, .vLimeDarker])

case .s4:
return (.vPink, .vPinkA50)
return Gradient(colors: [.vPink, .vPinkDarker])

case .s5:
return (.vOrange, .vOrangeA50)
return Gradient(colors: [.vOrange, .vOrangeDarker])

case .s6:
return (.vBlue, .vBlueA50)
return Gradient(colors: [.vBlue, .vBlueDarker])
}
}

Expand All @@ -44,25 +44,30 @@ enum NoAvatarSalt: Int, CaseIterable {
struct NoAvatar: View {
let salt: NoAvatarSalt
let name: String
let size: CGFloat

init(salt: String?, name: String) {
init(salt: String?, name: String, size: CGFloat = Avatar.defaultSize) {
let saltInt = Int(salt?.bytes.last ?? 0) % NoAvatarSalt.allCases.count
self.salt = NoAvatarSalt(rawValue: saltInt) ?? .s1
self.name = name
self.size = size
}

var body: some View {
let (strokeColor, fillColor) = self.salt.colors
let linearGradient = LinearGradient(
gradient: self.salt.gradient,
startPoint: .top,
endPoint: .bottom
)

Capsule()
.fill(fillColor)
.strokeBorder(strokeColor, lineWidth: 1)
.frame(width: 42, height: 42)
.fill(linearGradient)
.frame(width: self.size, height: self.size)
.overlay() {
Text(name.initials.uppercased())
.font(.system(size: 18))
.fontWeight(.semibold)
.foregroundStyle(strokeColor)
.fontWeight(.medium)
.foregroundStyle(.neutral1)
}
}
}
Expand Down
9 changes: 5 additions & 4 deletions app/App/Components/Buttons.swift
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@ struct PrimaryButtonStyle: ButtonStyle {
configuration.label
.background(.accent)
.clipShape(RoundedRectangle(cornerRadius: 10))
.shadow(color: .accent.opacity(0.2), radius: 15, y: 5)
.opacity(configuration.isPressed ? 0.7 : 1)
.animation(.easeOut(duration: 0.1), value: configuration.isPressed)
}
Expand Down Expand Up @@ -96,7 +97,7 @@ enum IconButtonSize {
return 36

case .large:
return 64
return 54

case .custom(let buttonSize, _):
return buttonSize
Expand All @@ -109,7 +110,7 @@ enum IconButtonSize {
return 12

case .large:
return 20
return 16

case .custom(_, let iconSize):
return iconSize
Expand Down Expand Up @@ -139,6 +140,7 @@ struct IconButtonStyle: ButtonStyle {
configuration.label
.background(self.priority.background)
.clipShape(Capsule())
.shadow(color: self.priority.background.opacity(0.2), radius: 8, y: 4)
.opacity(configuration.isPressed ? 0.7 : 1)
.animation(.easeOut(duration: 0.1), value: configuration.isPressed)
}
Expand Down Expand Up @@ -188,7 +190,6 @@ struct IconButtonWithTextModifier: ViewModifier {
VStack(spacing: 10) {
content
.preferredColorScheme(.dark)
.background(.background1)

Text(self.text).textTheme(.buttonIcon)
}
Expand Down Expand Up @@ -238,7 +239,7 @@ struct NoopButtonStyle: ButtonStyle {
}
.withText("Settings")

IconButton(size: .large) {} icon: {
IconButton(size: .large, priority: .primary) {} icon: {
Image("FaceID").iconify()
}
.withText("Face ID")
Expand Down
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
4 changes: 2 additions & 2 deletions app/App/Models/History.swift
Original file line number Diff line number Diff line change
Expand Up @@ -8,12 +8,12 @@
import Foundation

class User {
let nickname: String
let nickname: String?
let avatarUrl: String? = nil
let address: String?

init(transactionUser: RawTransactionUser) {
self.nickname = transactionUser.nickname ?? transactionUser.phone_number ?? "UNKNOWN"
self.nickname = transactionUser.nickname ?? transactionUser.phone_number
self.address = transactionUser.contract_address
}
}
Expand Down
12 changes: 11 additions & 1 deletion app/App/Navigation/ContentView.swift
Original file line number Diff line number Diff line change
Expand Up @@ -65,5 +65,15 @@ struct ContentView: View {
}

#Preview {
ContentView()
struct ContentViewPreviews: View {

@StateObject var model = Model()

var body: some View {
ContentView()
.environmentObject(self.model)
}
}

return ContentViewPreviews()
}
Loading

0 comments on commit 633fd91

Please sign in to comment.