| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137 |
- //
- // LineSDKFlexBubbleContainer.swift
- //
- // Copyright (c) 2016-present, LY Corporation. All rights reserved.
- //
- // You are hereby granted a non-exclusive, worldwide, royalty-free license to use,
- // copy and distribute this software in source code or binary form for use
- // in connection with the web services and APIs provided by LY Corporation.
- //
- // As with any software that integrates with the LY Corporation platform, your use of this software
- // is subject to the LINE Developers Agreement [http://terms2.line.me/LINE_Developers_Agreement].
- // This copyright notice shall be included in all copies or substantial portions of the software.
- //
- // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED,
- // INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
- // FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
- // IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM,
- // DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
- // OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
- //
- @objcMembers
- public class LineSDKFlexBubbleContainer: LineSDKFlexMessageContainer {
-
- public var header: LineSDKFlexBoxComponent?
- public var hero: LineSDKFlexImageComponent?
- public var body: LineSDKFlexBoxComponent?
- public var footer: LineSDKFlexBoxComponent?
-
- public var style: LineSDKFlexBubbleContainerStyle?
- public var direction: LineSDKFlexBubbleContainerDirection = .none
-
- public override init() { }
-
- convenience init(_ value: FlexBubbleContainer) {
- self.init()
- header = value.header.map { .init($0) }
- hero = value.hero.map { .init($0) }
- body = value.body.map { .init($0) }
- footer = value.footer.map { .init($0) }
-
- style = value.styles.map { .init($0) }
- direction = .init(value.direction)
- }
-
- override var unwrapped: FlexMessageContainer {
- var container = FlexBubbleContainer(
- header: header?.component,
- hero: hero?.component,
- body: body?.component,
- footer: footer?.component,
- styles: style?.unwrapped)
- container.direction = direction.unwrapped
- return .bubble(container)
- }
-
- var bubble: FlexBubbleContainer {
- return FlexBubbleContainer(header: nil, hero: nil, body: nil, footer: nil, styles: nil)
- }
- }
- @objcMembers
- public class LineSDKFlexBubbleContainerStyle: NSObject {
- public var header: LineSDKFlexBlockStyle?
- public var hero: LineSDKFlexBlockStyle?
- public var body: LineSDKFlexBlockStyle?
- public var footer: LineSDKFlexBlockStyle?
-
- public override init() {}
- public convenience init(_ value: FlexBubbleContainer.Style) {
- self.init()
- self.header = value.header.map { .init($0) }
- self.hero = value.hero.map { .init($0) }
- self.body = value.body.map { .init($0) }
- self.footer = value.footer.map { .init($0) }
- }
-
- var unwrapped: FlexBubbleContainer.Style {
- var style = FlexBubbleContainer.Style()
- style.header = header?.unwrapped
- style.hero = hero?.unwrapped
- style.body = body?.unwrapped
- style.footer = footer?.unwrapped
- return style
- }
- }
- @objc
- public enum LineSDKFlexBubbleContainerDirection: Int {
- case none
- case leftToRight
- case rightToLeft
-
- var unwrapped: FlexBubbleContainer.Direction? {
- switch self {
- case .none: return nil
- case .leftToRight: return .leftToRight
- case .rightToLeft: return .rightToLeft
- }
- }
-
- init(_ value: FlexBubbleContainer.Direction?) {
- switch value {
- case .leftToRight?: self = .leftToRight
- case .rightToLeft?: self = .rightToLeft
- case nil: self = .none
- }
- }
- }
- @objcMembers
- public class LineSDKFlexBlockStyle: NSObject {
-
- public var backgroundColor: LineSDKHexColor?
- public var separator: Bool
- public var separatorColor: LineSDKHexColor?
-
- public init(backgroundColor: LineSDKHexColor?, separator: Bool, separatorColor: LineSDKHexColor?) {
- self.backgroundColor = backgroundColor
- self.separator = separator
- self.separatorColor = separatorColor
- }
-
- public convenience init(_ value: FlexBlockStyle) {
- self.init(
- backgroundColor: value.backgroundColor.map { .init($0) },
- separator: value.separator ?? false,
- separatorColor: value.separatorColor.map { .init($0) })
- }
-
- var unwrapped: FlexBlockStyle {
- return FlexBlockStyle(
- backgroundColor: backgroundColor?.unwrapped,
- separator: separator,
- separatorColor: separatorColor?.unwrapped)
- }
- }
|