Is Android’s alert dialog already supported in Fuse library yet?
I took a look in version 1.6’s library directory and found Fuse.Alerts in it. Is it the same thing as native dialog? If it is, How I can use it?
Hi Riva,
Fuse.Alerts
package allows you to show native “confirm” and “alert” dialogs. It is weird that it’s missing from our docs, so we’ll look into that.
As for using it, it’s quite simple. First, you need to add "Fuse.Alerts"
under "Packages"
in your .unoproj file, and then go wild with the dialogs:
<App>
<JavaScript>
var Alerts = require("FuseJS/Alerts");
function showAlert() {
Alerts.alert("Alert", "description", "OK").then(function(x) {
console.log("alert closed, got: " + x);
});
}
function showConfirm() {
Alerts.confirm("Confirm", "description", "YES", "NO").then(function(x) {
console.log("confirm closed, got: " + x);
});
}
module.exports = {
showAlert: showAlert,
showConfirm: showConfirm
};
</JavaScript>
<StackPanel Alignment="VerticalCenter" ItemSpacing="4">
<Panel Width="128" Height="48" Clicked="{showAlert}">
<Text Value="Show alert" Color="#fff" Alignment="Center" />
<Rectangle CornerRadius="2" Color="#18f" />
</Panel>
<Panel Width="128" Height="48" Clicked="{showConfirm}">
<Text Value="Show confirm" Color="#fff" Alignment="Center" />
<Rectangle CornerRadius="2" Color="#18f" />
</Panel>
</StackPanel>
</App>
Note that the dialogs only show up on mobile devices, and do nothing in local preview.
This package also isn’t currently supported when previewing via the “Fuse Preview” mobile app, so make sure you deploy your builds over USB.
Hope this helps!
Sweet! Cannot wait to try this for my app!