Sha256: e9167145cc17d8b5fbd8a6f210303b52bfc167a235ca818742c01f028e47e181

Contents?: true

Size: 1.07 KB

Versions: 18

Compression:

Stored size: 1.07 KB

Contents

import Foundation
import Strada
import UIKit

final class FlashMessageComponent: BridgeComponent {
    override class var name: String { "flash-message" }

    override func onReceive(message: Message) {
        guard let event = Event(rawValue: message.event) else {
            return
        }

        if event == .connect {
            handleConnectEvent(message: message)
        }
    }

    @objc func performAction() {
        reply(to: Event.connect.rawValue)
    }

    // MARK: Private

    private var viewController: UIViewController? {
        delegate.destination as? UIViewController
    }

    private func handleConnectEvent(message: Message) {
        guard let data: MessageData = message.data() else { return }
        guard let viewController else { return }        
        viewController.parent?.presentToast(data.title)
    }
}

// MARK: Events

private extension FlashMessageComponent {
    enum Event: String { case connect }
}

// MARK: Message data

private extension FlashMessageComponent {
    struct MessageData: Decodable {
        let title: String
    }
}

Version data entries

18 entries across 9 versions & 1 rubygems

Version Path
turbo-native-initializer-0.0.19 lib/turbo_native_initializer/templates/ios_stack/TurboNativeProject/Strada/FlashMessageComponent.swift
turbo-native-initializer-0.0.19 lib/turbo_native_initializer/templates/ios_tabs/TurboNativeProject/Strada/FlashMessageComponent.swift
turbo-native-initializer-0.0.18 lib/turbo_native_initializer/templates/ios_stack/TurboNativeProject/Strada/FlashMessageComponent.swift
turbo-native-initializer-0.0.18 lib/turbo_native_initializer/templates/ios_tabs/TurboNativeProject/Strada/FlashMessageComponent.swift
turbo-native-initializer-0.0.17 lib/turbo_native_initializer/templates/ios_tabs/TurboNativeProject/Strada/FlashMessageComponent.swift
turbo-native-initializer-0.0.17 lib/turbo_native_initializer/templates/ios_stack/TurboNativeProject/Strada/FlashMessageComponent.swift
turbo-native-initializer-0.0.16 lib/turbo_native_initializer/templates/ios_stack/TurboNativeProject/Strada/FlashMessageComponent.swift
turbo-native-initializer-0.0.16 lib/turbo_native_initializer/templates/ios_tabs/TurboNativeProject/Strada/FlashMessageComponent.swift
turbo-native-initializer-0.0.15 lib/turbo_native_initializer/templates/ios_tabs/TurboNativeProject/Strada/FlashMessageComponent.swift
turbo-native-initializer-0.0.15 lib/turbo_native_initializer/templates/ios_stack/TurboNativeProject/Strada/FlashMessageComponent.swift
turbo-native-initializer-0.0.14 lib/turbo_native_initializer/templates/ios_tabs/TurboNativeProject/Strada/FlashMessageComponent.swift
turbo-native-initializer-0.0.14 lib/turbo_native_initializer/templates/ios_stack/TurboNativeProject/Strada/FlashMessageComponent.swift
turbo-native-initializer-0.0.13 lib/turbo_native_initializer/templates/ios_tabs/TurboNativeProject/Strada/FlashMessageComponent.swift
turbo-native-initializer-0.0.13 lib/turbo_native_initializer/templates/ios_stack/TurboNativeProject/Strada/FlashMessageComponent.swift
turbo-native-initializer-0.0.12 lib/turbo_native_initializer/templates/ios_stack/TurboNativeProject/Strada/FlashMessageComponent.swift
turbo-native-initializer-0.0.12 lib/turbo_native_initializer/templates/ios_tabs/TurboNativeProject/Strada/FlashMessageComponent.swift
turbo-native-initializer-0.0.11 lib/turbo_native_initializer/templates/ios_tabs/TurboNativeProject/Strada/FlashMessageComponent.swift
turbo-native-initializer-0.0.11 lib/turbo_native_initializer/templates/ios_stack/TurboNativeProject/Strada/FlashMessageComponent.swift