49 lines
1.9 KiB
Swift
49 lines
1.9 KiB
Swift
import Flutter
|
|
import UIKit
|
|
|
|
/// Keeps the system LaunchScreen as the only splash. Flutter would otherwise
|
|
/// instantiate that storyboard again and the icon appears a second time.
|
|
final class RunnerFlutterViewController: FlutterViewController {
|
|
override func loadDefaultSplashScreenView() -> Bool {
|
|
false
|
|
}
|
|
|
|
override func viewDidLoad() {
|
|
super.viewDidLoad()
|
|
view.backgroundColor = UIColor(red: 16.0 / 255.0, green: 12.0 / 255.0, blue: 10.0 / 255.0, alpha: 1)
|
|
}
|
|
}
|
|
|
|
@main
|
|
@objc class AppDelegate: FlutterAppDelegate, FlutterImplicitEngineDelegate {
|
|
override func application(
|
|
_ application: UIApplication,
|
|
didFinishLaunchingWithOptions launchOptions: [UIApplication.LaunchOptionsKey: Any]?
|
|
) -> Bool {
|
|
UIApplication.shared.isIdleTimerDisabled = true
|
|
return super.application(application, didFinishLaunchingWithOptions: launchOptions)
|
|
}
|
|
|
|
func didInitializeImplicitFlutterEngine(_ engineBridge: FlutterImplicitEngineBridge) {
|
|
GeneratedPluginRegistrant.register(with: engineBridge.pluginRegistry)
|
|
let channel = FlutterMethodChannel(
|
|
name: "com.stormg.lumadrama/share",
|
|
binaryMessenger: engineBridge.applicationRegistrar.messenger()
|
|
)
|
|
channel.setMethodCallHandler { [weak self] call, result in
|
|
guard call.method == "shareText",
|
|
let arguments = call.arguments as? [String: Any],
|
|
let text = arguments["text"] as? String,
|
|
!text.isEmpty,
|
|
let controller = self?.window?.rootViewController else {
|
|
result(FlutterError(code: "share_unavailable", message: "Share sheet is unavailable", details: nil))
|
|
return
|
|
}
|
|
let activity = UIActivityViewController(activityItems: [text], applicationActivities: nil)
|
|
activity.popoverPresentationController?.sourceView = controller.view
|
|
activity.completionWithItemsHandler = { _, _, _, _ in result(nil) }
|
|
controller.present(activity, animated: true)
|
|
}
|
|
}
|
|
}
|