-
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.
Introduce disabled state for ChatMessageEntry style
Introduce disabled state for ChatMessageEntry style for SC 2.0. MOB-3748
- Loading branch information
1 parent
14d76ce
commit 000092a
Showing
23 changed files
with
446 additions
and
226 deletions.
There are no files selected for viewing
Large diffs are not rendered by default.
Oops, something went wrong.
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
5 changes: 5 additions & 0 deletions
5
GliaWidgets/Sources/Component/Button/Message/MessageButton.StateStyle.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,5 @@ | ||
import Foundation | ||
|
||
extension MessageButton { | ||
typealias StateStyle = StatefulStyle<MessageButtonStateStyle> | ||
} |
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
29 changes: 29 additions & 0 deletions
29
GliaWidgets/Sources/Component/Button/Message/MessageButtonStateStyle.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,29 @@ | ||
import UIKit | ||
|
||
/// Style for state of the button shown to the right of the message input area. | ||
/// Used for "Send message" and "Pick attachment" buttons. | ||
public struct MessageButtonStateStyle { | ||
/// Image of the button. | ||
public var image: UIImage | ||
|
||
/// Color of the button's image. | ||
public var color: UIColor | ||
|
||
/// Accessibility related properties. | ||
public var accessibility: Accessibility | ||
|
||
/// - Parameters: | ||
/// - image: Image of the button. | ||
/// - color: Color of the button's image. | ||
/// - accessibility: Accessibility related properties. | ||
/// | ||
public init( | ||
image: UIImage, | ||
color: UIColor, | ||
accessibility: Accessibility = .unsupported | ||
) { | ||
self.image = image | ||
self.color = color | ||
self.accessibility = accessibility | ||
} | ||
} |
33 changes: 12 additions & 21 deletions
33
GliaWidgets/Sources/Component/Button/Message/MessageButtonStyle.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 |
---|---|---|
@@ -1,29 +1,20 @@ | ||
import UIKit | ||
import Foundation | ||
|
||
/// Style of a button shown to the right of the message input area. | ||
/// Used for "Send message" and "Pick attachment" buttons. | ||
/// Style for the button shown to the right of the message input area. | ||
public struct MessageButtonStyle { | ||
/// Image of the button. | ||
public var image: UIImage | ||
|
||
/// Color of the button's image. | ||
public var color: UIColor | ||
|
||
/// Accessibility related properties. | ||
public var accessibility: Accessibility | ||
/// Style for enabled state of the button. | ||
public var enabled: MessageButtonStateStyle | ||
/// Style for disabled state of the button. | ||
public var disabled: MessageButtonStateStyle | ||
|
||
/// - Parameters: | ||
/// - image: Image of the button. | ||
/// - color: Color of the button's image. | ||
/// - accessibility: Accessibility related properties. | ||
/// | ||
/// - enabled: Style for enabled state of the button. | ||
/// - disabled: Style for disabled state of the button. | ||
public init( | ||
image: UIImage, | ||
color: UIColor, | ||
accessibility: Accessibility = .unsupported | ||
enabled: MessageButtonStateStyle, | ||
disabled: MessageButtonStateStyle | ||
) { | ||
self.image = image | ||
self.color = color | ||
self.accessibility = accessibility | ||
self.enabled = enabled | ||
self.disabled = disabled | ||
} | ||
} |
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,31 @@ | ||
/// Stateful style to represent enabled and disabled states of the component. | ||
/// Simplifies access to underlying properties of the generic `State` type. | ||
@dynamicMemberLookup | ||
enum StatefulStyle<State> { | ||
/// Enabled state. | ||
case enabled(State) | ||
/// Disabled state. | ||
case disabled(State) | ||
|
||
subscript<T>(dynamicMember keyPath: WritableKeyPath<State, T>) -> T { | ||
get { | ||
switch self { | ||
case let .enabled(style): | ||
return style[keyPath: keyPath] | ||
case let .disabled(style): | ||
return style[keyPath: keyPath] | ||
} | ||
} | ||
|
||
set (newValue) { | ||
switch self { | ||
case var .enabled(style): | ||
style[keyPath: keyPath] = newValue | ||
self = .enabled(style) | ||
case var .disabled(style): | ||
style[keyPath: keyPath] = newValue | ||
self = .disabled(style) | ||
} | ||
} | ||
} | ||
} |
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
53 changes: 53 additions & 0 deletions
53
GliaWidgets/Sources/View/Chat/Entry/ChatMessageEntryStateStyle.RemoteConfig.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,53 @@ | ||
import UIKit | ||
|
||
extension ChatMessageEntryStateStyle { | ||
mutating func apply( | ||
configuration: RemoteConfiguration.Input?, | ||
assetsBuilder: RemoteConfiguration.AssetsBuilder | ||
) { | ||
configuration?.background?.color?.value | ||
.map { UIColor(hex: $0) } | ||
.first | ||
.unwrap { backgroundColor = $0 } | ||
|
||
configuration?.text?.foreground?.value | ||
.map { UIColor(hex: $0) } | ||
.first | ||
.unwrap { messageColor = $0 } | ||
|
||
UIFont.convertToFont( | ||
uiFont: assetsBuilder.fontBuilder(configuration?.text?.font), | ||
textStyle: messageTextStyle | ||
).unwrap { messageFont = $0 } | ||
|
||
configuration?.placeholder?.foreground?.value | ||
.map { UIColor(hex: $0) } | ||
.first | ||
.unwrap { placeholderColor = $0 } | ||
|
||
UIFont.convertToFont( | ||
uiFont: assetsBuilder.fontBuilder(configuration?.placeholder?.font), | ||
textStyle: placeholderTextStyle | ||
).unwrap { placeholderFont = $0 } | ||
|
||
configuration?.separator?.value | ||
.map { UIColor(hex: $0) } | ||
.first | ||
.unwrap { separatorColor = $0 } | ||
// TODO: Add Unified customization (MOB-3762) | ||
configuration?.mediaButton?.tintColor?.value | ||
.map { UIColor(hex: $0) } | ||
.first | ||
.unwrap { mediaButton.enabled.color = $0 } | ||
// TODO: Add Unified customization (MOB-3762) | ||
configuration?.sendButton?.tintColor?.value | ||
.map { UIColor(hex: $0) } | ||
.first | ||
.unwrap { sendButton.enabled.color = $0 } | ||
|
||
uploadList.apply( | ||
configuration: configuration?.fileUploadBar, | ||
assetsBuilder: assetsBuilder | ||
) | ||
} | ||
} |
Oops, something went wrong.