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
/** | |
* Authenticator that attempts to refresh the client's access token. | |
* In the event that a refresh fails and a new token can't be issued an error | |
* is delivered to the caller. This authenticator blocks all requests while a token | |
* refresh is being performed. In-flight requests that fail with a 401 are | |
* automatically retried. | |
*/ | |
class AccessTokenAuthenticator( | |
private val tokenProvider: AccessTokenProvider | |
) : Authenticator { |
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
extension DataRow: ViewModelConvertible { | |
func viewModel(context: SDUIContext) -> some ViewModel { | |
return DataRowViewModel( | |
title: self.title, | |
titleURL: self.titleHyperlink, | |
subtitle: self.subtitle, | |
layout: self.layout.toNativeLayout(), | |
accessory: accessoryView?.viewModel(context: context) | |
) | |
} |
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
public struct DataRow: Codable, Equatable { | |
public let title: String | |
public let subtitle: String | |
public let layout: Layout | |
public let titleHyperlink: URL? | |
public let accessoryView: SDUIComponent? | |
public enum Layout: String { | |
case vertical = "VERTICAL" |
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
class DataRow(UIComponent): | |
title: str | |
subtitle: str | |
layout: Layout = Layout.HORIZONTAL | |
title_hyperlink: Optional[Url] = None | |
accessory_view = Optional[UIComponent] = None | |
@classmethod | |
def component_type(cls) -> ComponentType: | |
return ComponentType.DATA_ROW_STACKED |
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
class DataRow(UIComponent): | |
title: str | |
subtitle: str | |
layout: Layout = Layout.HORIZONTAL | |
@classmethod | |
def component_type(cls) -> ComponentType: | |
return ComponentType.DATA_ROW_STACKED | |
class Layout(str, Enum): |
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
func viewModel(context: SDUIContext) -> ViewModel |
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
class Action(BaseModel, ABC): | |
sdui_action_type: ActionType | |
def __init__(self, **data) -> None: | |
data['sdui_action_type'] = self.action_type() | |
super().__init__(**data) | |
@classmethod | |
@abstractmethod | |
def action_type(cls) -> ActionType: |
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
extension SDUIComponent { | |
private var concreteModel: Any { | |
switch self { | |
case .button(let button): | |
return button | |
case .row(let row): | |
return row | |
case .text(let text): | |
return text | |
} |
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
SDUIComponent = SDUIButton | SDUIRow | SDUIText |
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
sealed interface SDUIComponent | |
data class SDUIButton: SDUIComponent | |
data class SDUIRow: SDUIComponent | |
data class SDUIText: SDUIComponent |
NewerOlder