-
Notifications
You must be signed in to change notification settings - Fork 5
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Feat HintView Alignment & Button Customization (#283)
* Add alignment * Can set hintview button and format code * Update sample * Use configuration for button style * Update CharcoalButton.swift
- Loading branch information
Showing
12 changed files
with
355 additions
and
303 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
38 changes: 38 additions & 0 deletions
38
Sources/CharcoalSwiftUI/Components/Buttons/CharcoalButton.swift
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,38 @@ | ||
import SwiftUI | ||
|
||
public protocol CharcoalButtonModifier: ViewModifier {} | ||
|
||
public enum CharcoalButtonStyle { | ||
case primary(Configuration) | ||
case `default` | ||
|
||
@ViewBuilder | ||
func apply<Content: View>(_ content: Content) -> some View { | ||
switch self { | ||
case let .primary(configuration): | ||
content.charcoalPrimaryButton(size: configuration.size, isFixed: configuration.isFixed, primaryColor: configuration.primaryColor) | ||
case .default: | ||
content.charcoalDefaultButton(size: .medium, isFixed: true) | ||
} | ||
} | ||
} | ||
|
||
extension CharcoalButtonStyle { | ||
public struct Configuration { | ||
public var size: CharcoalButtonSize | ||
public var isFixed: Bool | ||
public var primaryColor: Color | ||
|
||
public init(size: CharcoalButtonSize = .medium, isFixed: Bool = true, primaryColor: Color) { | ||
self.size = size | ||
self.isFixed = isFixed | ||
self.primaryColor = primaryColor | ||
} | ||
} | ||
} | ||
|
||
extension View { | ||
func charcoalButtonStyle(_ style: CharcoalButtonStyle) -> some View { | ||
style.apply(self) | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.