Skip to content

Commit

Permalink
add fontColor
Browse files Browse the repository at this point in the history
  • Loading branch information
tsuzukihashi committed Mar 13, 2020
1 parent b616085 commit a15e5a9
Show file tree
Hide file tree
Showing 2 changed files with 21 additions and 0 deletions.
10 changes: 10 additions & 0 deletions Sources/NeumorphismManager.swift
Original file line number Diff line number Diff line change
@@ -1,7 +1,9 @@
import SwiftUI

@available(iOS 13.0, *)
public protocol NeumorphismManagable {
func changeMode()
func fontColor(lightColor: Color?, darkColor: Color?) -> Color
}

@available(iOS 13.0, *)
Expand Down Expand Up @@ -29,4 +31,12 @@ public class NeumorphismManager: NeumorphismManagable, ObservableObject {
UserDefaults.standard.set(false, forKey: "isDark")
}
}

public func fontColor(lightColor: Color?, darkColor: Color?) -> Color {
if isDark {
return lightColor ?? self.lightColor
} else {
return darkColor ?? self.darkColor
}
}
}
11 changes: 11 additions & 0 deletions Tests/Mock/NeumorphismManagerMock.swift
Original file line number Diff line number Diff line change
@@ -1,5 +1,16 @@
import SwiftUI

@available(iOS 13.0, *)
class NeumorphismManagerMock: NeumorphismManagable {
var fontColorCallCount = 0
var fontColorArgs: (lightColor: Color?, darkColor: Color?)?
func fontColor(lightColor: Color?, darkColor: Color?) -> Color {
fontColorCallCount += 1
fontColorArgs?.lightColor = lightColor
fontColorArgs?.darkColor = darkColor
return lightColor ?? Color.white
}

var changeModeCallCount = 0
func changeMode() {
changeModeCallCount += 1
Expand Down

0 comments on commit a15e5a9

Please sign in to comment.