From 66c29490d403ac2ecd8a68a7b1a717c6252c51a1 Mon Sep 17 00:00:00 2001 From: Max Desiatov Date: Sat, 1 Aug 2020 19:38:57 +0100 Subject: [PATCH] Fix tests, move DefaultButtonStyle to TokamakCore --- Sources/TokamakCore/Styles/ButtonStyle.swift | 9 ++++++++- .../TokamakCore/Views/Buttons/Button.swift | 8 ++++---- Sources/TokamakDOM/DOMRenderer.swift | 1 - Sources/TokamakDOM/Styles/ButtonStyle.swift | 6 ------ Sources/TokamakTestRenderer/TestView.swift | 4 +++- Tests/TokamakTests/ReconcilerTests.swift | 20 +++++++++---------- 6 files changed, 25 insertions(+), 23 deletions(-) diff --git a/Sources/TokamakCore/Styles/ButtonStyle.swift b/Sources/TokamakCore/Styles/ButtonStyle.swift index 6c68e6de8..374d77dd4 100644 --- a/Sources/TokamakCore/Styles/ButtonStyle.swift +++ b/Sources/TokamakCore/Styles/ButtonStyle.swift @@ -26,6 +26,13 @@ public struct ButtonStyleConfiguration { public let isPressed: Bool } +public struct DefaultButtonStyle: ButtonStyle { + public init() {} + public func makeBody(configuration: ButtonStyleConfiguration) -> some View { + configuration.label + } +} + /// This is a helper class that works around absence of "package private" access control in Swift public struct _ButtonStyleConfigurationProxy { public struct Label { @@ -75,7 +82,7 @@ public struct _AnyButtonStyle: ButtonStyle { public enum _ButtonStyleKey: EnvironmentKey { public static var defaultValue: _AnyButtonStyle { - fatalError("\(self) must have a renderer-provided default value") + _AnyButtonStyle(DefaultButtonStyle()) } } diff --git a/Sources/TokamakCore/Views/Buttons/Button.swift b/Sources/TokamakCore/Views/Buttons/Button.swift index f99872e71..b0898ed9f 100644 --- a/Sources/TokamakCore/Views/Buttons/Button.swift +++ b/Sources/TokamakCore/Views/Buttons/Button.swift @@ -36,14 +36,14 @@ /// Button("\(counter)", action: { counter += 1 }) /// } public struct Button