Skip to content

Commit

Permalink
ADD: Dark Mode Support
Browse files Browse the repository at this point in the history
  • Loading branch information
Mercen-Lee committed Oct 16, 2023
1 parent feb852e commit 8e6f524
Show file tree
Hide file tree
Showing 5 changed files with 21 additions and 24 deletions.
17 changes: 7 additions & 10 deletions Sources/OpenTDS/Component/Example/ExampleView.swift
Original file line number Diff line number Diff line change
Expand Up @@ -3,18 +3,15 @@ import SwiftUI
struct ExampleView: View {
var body: some View {
TossTabView {
VStack {
Text("a")
}
.tossTabItem("Home", Image(systemName: "house.fill"))
Text("b")
.tossTabItem("My", Image(systemName: "person.fill"))
Text("View1")
.tossTabItem("View1", Image(systemName: "house.fill"))
Text("View2")
.tossTabItem("View2", Image(systemName: "person.fill"))
}
.font(.system(size: 30))
}
}

struct Example_Previews: PreviewProvider {
static var previews: some View {
ExampleView()
}
#Preview {
ExampleView()
}
2 changes: 1 addition & 1 deletion Sources/OpenTDS/Component/ScrollView/ScrollView.swift
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,7 @@ public struct TossScrollView<Content: View>: View {
TossIcon.chevron
.resizable()
.frame(width: 10.14, height: 17.77)
.foregroundColor(Color(.label))
.foregroundColor(TossColor.label)
}
}
Spacer()
Expand Down
5 changes: 3 additions & 2 deletions Sources/OpenTDS/Component/TabView/TabView+Button.swift
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@ public struct TossTabViewButton: View {
ZStack {
if rectangleState {
RoundedRectangle(cornerRadius: 18)
.foregroundColor(TossColor.generalBackground)
.foregroundColor(TossColor.secondaryBackground)
}
VStack(spacing: 3) {
image
Expand All @@ -57,11 +57,12 @@ public struct TossTabViewButton: View {
.padding(2)
.scaleEffect(x: animationState == 2 ? 1.1 : 1, y: 1)
.scaleEffect(x: 1, y: animationState == 3 ? 1.05 : 1)
.foregroundColor(selected || touchdownState ? TossColor.label : TossColor.tabViewButtonIcon)
Text(label)
.font(.system(size: 11, weight: .medium))
.scaleEffect(animationState == 2 ? 1.05 : 1)
.foregroundColor(selected || touchdownState ? TossColor.label : TossColor.tabViewButtonLabel)
}
.foregroundColor(selected || touchdownState ? TossColor.general : TossColor.secondary)
}
.frame(width: 56, height: 56)
.scaleEffect(animationState == 1 ? 0.9 : 1)
Expand Down
6 changes: 3 additions & 3 deletions Sources/OpenTDS/Component/TabView/TabView.swift
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ public struct TossTabView: View {
GeometryReader { geometry in
ZStack(alignment: .bottom) {
ZStack {
ForEach(0..<content.count, id: \.self) { idx in
ForEach(content.indices, id: \.self) { idx in
content[idx].content
.offset(x: { () -> CGFloat in
if idx == selected {
Expand All @@ -49,7 +49,7 @@ public struct TossTabView: View {

HStack {
Spacer()
ForEach(0..<content.count, id: \.self) { idx in
ForEach(content.indices, id: \.self) { idx in
TossTabViewButton(content[idx].title,
content[idx].image,
idx == selected) {
Expand All @@ -64,7 +64,7 @@ public struct TossTabView: View {
}
.padding(.vertical, 3)
.padding(.bottom, 100)
.background(Color(.systemBackground))
.background(TossColor.background)
.cornerRadius(20)
.overlay(RoundedRectangle(cornerRadius: 20)
.strokeBorder(TossColor.stripe, lineWidth: 0.3))
Expand Down
15 changes: 7 additions & 8 deletions Sources/OpenTDS/Foundation/Color/TossColor.swift
Original file line number Diff line number Diff line change
Expand Up @@ -25,12 +25,11 @@ public enum TossColor {
}

extension TossColor {

public static let main: Color = dynamicColor("#3250FF", dark: "#FFFFFF")
public static let general: Color = dynamicColor("#1A1E27", dark: "#FFFFFF")
public static let generalBackground: Color = dynamicColor("#F5F5F9", dark: "#FFFFFF")
public static let label: Color = dynamicColor("#1A1E27", dark: "#FFFFFF")
public static let secondary: Color = dynamicColor("#B1B8C0", dark: "#FFFFFF")
public static let stripe: Color = dynamicColor("#E5E8EB", dark: "#FFFFFF")
public static let background: Color = dynamicColor("#F2F4F6", dark: "#FFFFFF")

public static let tabViewButtonIcon: Color = dynamicColor("#B1B8C0", dark: "#62626D")
public static let tabViewButtonLabel: Color = dynamicColor("#6D7582", dark: "#9E9EA4")
public static let background: Color = dynamicColor("#FFFFFF", dark: "#17171C")
public static let label: Color = dynamicColor("#1A1E27", dark: "#FFFFFF")
public static let stripe: Color = dynamicColor("#E4E8EB", dark: "#3C3C47")
public static let secondaryBackground: Color = dynamicColor("#F2F3F5", dark: "#2C2C35")
}

0 comments on commit 8e6f524

Please sign in to comment.