From a15e5a9fb3d38eadfc8a9972dfe6f909470ea10e Mon Sep 17 00:00:00 2001 From: tsuzukihashi Date: Fri, 13 Mar 2020 18:47:10 +0900 Subject: [PATCH] add fontColor --- Sources/NeumorphismManager.swift | 10 ++++++++++ Tests/Mock/NeumorphismManagerMock.swift | 11 +++++++++++ 2 files changed, 21 insertions(+) diff --git a/Sources/NeumorphismManager.swift b/Sources/NeumorphismManager.swift index e8d8bbd..2072071 100644 --- a/Sources/NeumorphismManager.swift +++ b/Sources/NeumorphismManager.swift @@ -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, *) @@ -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 + } + } } diff --git a/Tests/Mock/NeumorphismManagerMock.swift b/Tests/Mock/NeumorphismManagerMock.swift index 47e8f43..254e056 100644 --- a/Tests/Mock/NeumorphismManagerMock.swift +++ b/Tests/Mock/NeumorphismManagerMock.swift @@ -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