-
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(Button): Added accesibility to right image (chevron)
- Loading branch information
1 parent
ca9008c
commit 05d77d9
Showing
7 changed files
with
140 additions
and
24 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
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
65 changes: 65 additions & 0 deletions
65
Sources/MisticaSwiftUI/Components/Button/ScaledMisticaButton.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,65 @@ | ||
// | ||
// ScaledMisticaButton.swift | ||
// | ||
// Made with ❤️ by Novum | ||
// | ||
// Copyright © Telefonica. All rights reserved. | ||
// | ||
|
||
import SwiftUI | ||
|
||
@available(iOS 14.0, *) | ||
struct ScaledMisticaButton<Content: View>: View { | ||
let content: () -> Content | ||
let height: CGFloat | ||
let small: Bool | ||
let minWidth: CGFloat | ||
let verticalPadding: CGFloat | ||
let horizontalPadding: CGFloat | ||
let backgroundColor: Color | ||
let foregroundColor: Color | ||
let borderColor: Color | ||
let leadingInset: CGFloat | ||
let trailingInset: CGFloat | ||
|
||
@ScaledMetric var scale: CGFloat = 1 | ||
|
||
init( | ||
height: CGFloat, | ||
small: Bool, | ||
minWidth: CGFloat, | ||
verticalPadding: CGFloat, | ||
horizontalPadding: CGFloat, | ||
backgroundColor: Color, | ||
foregroundColor: Color, | ||
borderColor: Color, | ||
leadingInset: CGFloat, | ||
trailingInset: CGFloat, | ||
@ViewBuilder content: @escaping () -> Content | ||
) { | ||
self.height = height | ||
self.small = small | ||
self.minWidth = minWidth | ||
self.content = content | ||
self.verticalPadding = verticalPadding | ||
self.horizontalPadding = horizontalPadding | ||
self.backgroundColor = backgroundColor | ||
self.foregroundColor = foregroundColor | ||
self.borderColor = borderColor | ||
self.leadingInset = leadingInset | ||
self.trailingInset = trailingInset | ||
} | ||
|
||
var body: some View { | ||
content() | ||
.frame(height: height * scale) | ||
.if(!small) { $0.expandHorizontally() } | ||
.frame(minWidth: minWidth * scale) | ||
.padding(.vertical, verticalPadding) | ||
.padding(.horizontal, horizontalPadding) | ||
.background(backgroundColor) | ||
.foregroundColor(foregroundColor) | ||
.border(radiusStyle: .button, borderColor: borderColor) | ||
.padding(EdgeInsets(top: 0, leading: leadingInset, bottom: 0, trailing: trailingInset)) | ||
} | ||
} |
Binary file modified
BIN
+897 Bytes
(100%)
...ts/UI/__Snapshots__/ButtonTests/testRegularSizeWithLinkInverseWithChevron.1.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified
BIN
+942 Bytes
(100%)
...ftUITests/UI/__Snapshots__/ButtonTests/testRegularSizeWithLinkWithChevron.1.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.