Skip to content

Commit

Permalink
Fix for resources PR remarks
Browse files Browse the repository at this point in the history
  • Loading branch information
Daeda88 committed Jan 26, 2022
1 parent 3c16e2e commit c164f51
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 6 deletions.
11 changes: 7 additions & 4 deletions stencils/KalugaButton+SwiftUI.stencil
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@ extension KalugaButton {
buttonView
}
.buttonStyle(CustomButtonStyle(kalugaButton: self))
.disabled(!self.isEnabled)
}
}

Expand All @@ -45,11 +46,11 @@ private extension KalugaButton {
return .leading
case TextAlignment.right:
return .trailing
case TextAlignment.opposite:
case TextAlignment.end:
return UIApplication.shared.userInterfaceLayoutDirection == .leftToRight ?
.trailing :
.leading
case TextAlignment.normal:
case TextAlignment.start:
return .leading
case TextAlignment.center:
return .center
Expand Down Expand Up @@ -96,13 +97,15 @@ private extension KalugaButton {
}

private func makeForegroundColor(isPressed: Bool) -> SwiftUI.Color {
if isPressed { return Color(kalugaButton.style.pressedStyle.textColor.uiColor) }
if !kalugaButton.isEnabled { return Color(kalugaButton.style.disabledStyle.textColor.uiColor) }
else if isPressed { return Color(kalugaButton.style.pressedStyle.textColor.uiColor) }
else { return Color(kalugaButton.style.defaultStyle.textColor.uiColor) }
}

private func makeShape(isPressed: Bool) -> some View {
let buttonStateStyle: ButtonStateStyle
if isPressed { buttonStateStyle = kalugaButton.style.pressedStyle }
if !kalugaButton.isEnabled { buttonStateStyle = kalugaButton.style.disabledStyle }
else if isPressed { buttonStateStyle = kalugaButton.style.pressedStyle }
else { buttonStateStyle = kalugaButton.style.defaultStyle}

return buttonStateStyle.backgroundStyle.toView()
Expand Down
4 changes: 2 additions & 2 deletions stencils/KalugaLabel+SwiftUI.stencil
Original file line number Diff line number Diff line change
Expand Up @@ -36,11 +36,11 @@ private extension KalugaLabel {
return .leading
case TextAlignment.right:
return .trailing
case TextAlignment.opposite:
case TextAlignment.end:
return UIApplication.shared.userInterfaceLayoutDirection == .leftToRight ?
.trailing :
.leading
case TextAlignment.normal:
case TextAlignment.start:
return .leading
case TextAlignment.center:
return .center
Expand Down

0 comments on commit c164f51

Please sign in to comment.