-
-
Save rylax/06fb1da2b8f118cd5a978fbb013243d1 to your computer and use it in GitHub Desktop.
Display Alert with Swift [Bug]
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
using Uno; | |
using Uno.Collections; | |
using Fuse; | |
using Fuse.Scripting; | |
using Uno.UX; | |
using Uno.Compiler.ExportTargetInterop; | |
[ForeignInclude(Language.ObjC, "@(Project.Name)-Swift.h")] | |
public class HelloSwift : NativeModule | |
{ | |
[Foreign(Language.ObjC)] | |
public static void hello() | |
@{ | |
HelloSwiftWorld* x = [[HelloSwiftWorld alloc] init]; | |
[x hello]; | |
@} | |
} | |
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
import Foundation | |
import UIKit | |
public class HelloSwiftWorld: NSObject { | |
public func hello() { | |
let alert = UIAlertController(title: "Did you bring your towel?", message: "It's recommended you bring your towel before continuing.", preferredStyle: .alert) | |
alert.addAction(UIAlertAction(title: "Yes", style: .default, handler: nil)) | |
alert.addAction(UIAlertAction(title: "No", style: .cancel, handler: nil)) | |
self.present(alert, animated: true) | |
} | |
} |
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
<App> | |
<DockPanel> | |
<StatusBarBackground Dock="Top" /> | |
<BottomBarBackground Dock="Bottom" /> | |
<HelloSwift ux:Global="HelloSwift" /> | |
<JavaScript> | |
var HelloSwift = require("HelloSwift") | |
function button_pressed_fromSwift() { | |
HelloSwift.hello(); | |
} | |
module.exports = { | |
button_pressed_fromSwift: button_pressed_fromSwift | |
}; | |
</JavaScript> | |
<StackPanel Margin="0,50,0,0"> | |
<Button Text="From Swift!" Clicked="{button_pressed_fromSwift}" /> | |
</StackPanel> | |
</DockPanel> | |
</App> | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment