I have some flow on my app that, in some moment, I push a page to the stack and, on that page, I call a loading dialog for some data load. The problem is that the loading dialog didn't showed up. Then I realized that when I got back to the previous page, the loading was there, under my page that was being showed up. If in my navigation flow, instead of nav.push I use nav.setRoot, it works fine, so I think it's some glitch with that navigation stack. I really wanna use nav.pushcause it makes more sense for my app.
Any ideas?
EDIT:
my function that call the page:
onViewUnidade(unidade){
if (unidade.tipo == "Unidade Consumidora"){
this.nav.push(UnidadeConsumidoraPage, unidade);
}else if (unidade.tipo == "Usina"){
this.nav.push(UsinaPage, unidade);
}
}
my onInit method:
ngOnInit(){
console.log("show loading");
this.loading = this.loadingCtrl.create({
content: "some message"
});
this.loading.present();
}
My console.log executes, and I even didn't dismissed it, so I could see it correctly. The Loading and LoadingController are properly imported and injected.
EDIT 2:
I noticed that issue only happens when the page that redirects to my last page with the loading is a modal. If I change it for a regular page, it works correctly. Also, tried to dismiss the modal and popToRoot before navigate to new page... but still gotting same issue. Any ideas?
got my answer on documentation:
Instead of injecting navigation controller, when you wanted to navigate from an overlay component (popover, modal, alert, etc), we have to get a reference of the root NavController in our app, using the getRootNav() method:
this.appCtrl.getRootNav().push(SecondPage);
Hope this helps who got the same problem!
Have a look at LoadingOptions
export interface LoadingOptions {
spinner?: string;
content?: string;
cssClass?: string;
showBackdrop?: boolean;
dismissOnPageChange?: boolean;
delay?: number;
duration?: number;
}
You can set dismissOnPageChange(to true). Make sure you dismiss the loading dialog or set duration.
Related
So I'm making a button for a "New Note" in Swift UI similar to the Apple Notes app.
Right now my "New Button" is a "Navigation Link" like so:
NavigationLink(
destination: EditorView(makeNewNote())
) {
Text("New")
}
Unfortunately—this triggers my app to create a new note every time the view loaded. :(
:/
I've been looking for a way to initate a segue on button push but I'm not finding success on this yet.
When I tried a modal—I found myself having the same problem
Button("New") {
self.isNew = true
}.sheet(isPresented: $isNew, content: {
EditorView(makeNewNote())
})
I'm wondering what the best way to approach this would be.
Having no success :(
Edit:
I referred to this and the documentation but I haven’t found a way to segue via a button push which would be ideal. (The function dosent get triggered in the closure :)
https://www.hackingwithswift.com/quick-start/swiftui/how-to-push-a-new-view-onto-a-
Also...if you were curious what makeNewButton() does—it basically inserts a new Core Data object into my app’s managed context.
I'm not entirely sure, but it kinda sounds like to me your problem lies in your model. Because each time your View loads it calls the makeNewButton() function right?
Maybe you can fix the problem by displaying the "new note" view and having an extra "Save" button that only makes changes to your model once it's triggered.
Alternatively, you could use context.rollback() to discard changes. Also, check out this Project. It's Beta 4 but works just the same and imo is a good example how to use CoreData with SwiftUI. :)
I have to disable standard next button, on my custom page via installscript.qs file.
I can disable my own button (that I created in .ui file) via .qs script like this: widget.myButton.setEnabled(false);
This man shows that native buttons represented as enumeration and I cannot disable them same way.
Controller Scripting manual page shows some interactions with native buttons. Like gui.clickButton(buttons.NextButton). I go through whole gui object man and don't found anything useful.
Qt installer framework has a native license check page with Next button logic that I need, but I have not found any samples that do it manually. (license page work because its default license page and it's logic inside framework as I understand).
Finally I found isComplete() method that can be useful for me, but it is for C++ API not for qs.
So how to disable native button via installscript.qs file?
In case someone else end ups here, I finally found a cleaner solution: a dynamic widget has a property complete that can be changed to enable and disable the "Next" button. Set it to false to disable the button.
Controller.prototype.DynamicMyWidgetCallback = function()
{
var currentWidget = gui.currentPageWidget();
if (currentWidget != null)
{
currentWidget.complete = false
}
}
The only solution i had found is call installer.setValue("canContinue" "false");
Then connect page entered event using gui.pageById(QInstaller.TargetDirectory).entered.
connect(Component.prototype.targetPageEntered);
In targetPageEntered check our value:
Component.prototype.targetPageEntered = function () {
if (installer.value("canContinue") != "true") {
gui.clickButton(buttons.BackButton);
QMessageBox.information("someid", "Installer",
"You must do smth to continue", QMessageBox.Ok);
}
}
Of course you need to change the installer.value when user complete required actions.
I need to understand the differences between ModalController and NavController in Ionic 2. When should I choose NavController and when to choose ModalController?
In the ModalController doc:
A modal uses the NavController to present itself in the root nav
stack. It is added to the stack similar to how NavController.push
works.
So we can say, in mechanism, they are the same. Lets talk about UX.
A Modal is a content pane that goes over the user's current page
A modal actually go over the page. It is like a popup. In small device, it take all the space of screen so you can not realize the diffentce from it and page. But if you test it in tablet like a ipad you will see the modal just take a part of screen and the current page is behind it.(Image description below).
What should be used?
In most case, you can use modal or page base on what you prefer but to ensure the properly UX modal should be used in case editing, making choice or getting information, other case page should be used
The ModalController is used to create and present modals. Modals are commonly used for galleries, edit forms, and other content that should be push on top of the current page.
import { ModalController } from 'ionic-angular';
import { Page1 } from './pages';
constructor(private modalCtrl: ModalController) {}
let modal = this.modalCtrl.create(Page1);
modal.present();
modal.onDidDismiss(() => {
// Action done after dismissing the modal.
});
The NavController is used for navigation functionality (think about Tabs or just basic page navigation). This controller also contains your navigation history.
import { NavController } from 'ionic-angular';
import { Page1 } from './pages';
constructor(private navCtrl: NavController) {
}
this.navCtrl.push(Page1);
So there are two different approaches to present the desired page. For more information/options/methods please ready the provided links, containing all available features available on the Modal- and NavController components.
I want to have the android back button to close the app if the user is on one of the two main pages. Both pages can be navigated to with two tabs button, which are shown on those both pages. But on any other pages I want to keep normal stack pages behaviour.
I read about registerBackButtonAction and also got some information in this thread concerning Ionic 1.
I created a custom behaviour to close the app:
private registerSpecificActionOnBackButton = () => {
if(this.platform.is('android')||this.platform.is('windows')){
this.platform.registerBackButtonAction(function(e){
this.platform.exitApp();
}.bind(this),101);
}
}
My idea is to call the registerSpecificActionOnBackButton() function in the ionViewWillEnter() function on the pages where this behaviour is needed.
But I don't manage to cancel that behaviour on the ionViewWillLeave() function with a deRegisterSpecificActionOnBackButton() function, I've tried among other things:
private deRegisterSpecificActionOnBackButton = () => {
if(this.platform.is('android')||this.platform.is('windows')){
this.platform.registerBackButtonAction(function(e){return true},101);
}
}
Or
private deRegisterSpecificActionOnBackButton = () => {
if(this.platform.is('android')||this.platform.is('windows')){
this.platform.registerBackButtonAction(function(event){event.unbind()},101);
}
}
But I happen to be stuck. Has anyone any idea about canceling a custom registerBackButtonAction?
I've managed to make this work as I expect: When the app is on one of the pages that can be reached thru the tabs menu, it closes when the back button is hitten (on Android).
First, forget about the registerBackButtonAction() for the moment because as quoting what is explained in this thread of 2016-08-05:
it suggests not trying to override the default back button behavior.
So I've looked for other solutions. I've found one that is not really clean but works.
To begin with, I looked if I could reset the stack with the NavControler using remove(startIndex, removeCount, opts). But that doesn't work out because the two main pages are embeded in the tab page (like it is shown there).
So when you're on one of those pages the NavController is a Tab and the parent of that is a Tabs.
In Tabs there is a Array variable named _selectHistory. The _selectHistory array seems to have a role similar to the stack. So when navigating from one page to another using the two tab buttons, one can see in a console.info(this.[NavControler var of the page].parent._selectHistory) that the array grows as the tab buttons are hitten alternatively. And when trying on a real device, the back button take you back switching from one page to another until the array is empty and then the next back button hit closes the app.
Hence I thought: Let see what happens if I override the value of that array. It cannot be done thru a function to apply on a Tabs object (unlike what is possible with NavController).
So in the Page concerning my pages embedded in the Tab page, I added the following in ionViewWillEnter():
ionViewWillEnter(){
this.navCtrl.parent._selectHistory=[];
}
This.navCtrl is my NavController object passed in the constructor of the page.
That's it.
I have a problem with the FreeTextBox rich Text Editor in my ASP.NET site. The problem occurs when I access the site with firefox, and I have a freetextbox instance in a hidden div. The hidden div might also be an AJAX Tab Panel. The actual problem is that when the page loads it throws an uncaught exception (firebug shows the StoreHtml() function) and halts the postback!!
Is anywhere of the problem and a solution for it??
Thanks
I recently met a similar problem with jQuery UI tabs. What you need to do is to change the CSS for hidden tabs to something like:
.hiddentab
{
position: absolute;
left: -99999999999999;
}
This puts hidden tabs far to the left, and in absolute position mode this does not cause horizontal scroll bars to appear. When the tab is shown, simply remove the hiddentab class from the tab element.
This will work if the problem is related to Firefox' odd behavior with display: none.
I have found another solution to the problem in case anyone is looking for it. What I did was use javascript to override the OnSubmit function of the form, thus catching the exception that caused the problem and going on with the rest of the code.
However the solution is kind of "hack" since it does not cover every situation. I found the solution in the FreeTextBox forum and tried it out and it works. The only difference in my code is that I return true in the end of the override function:
function OvrdSubmit()
{
var ftbSubmit=document.forms[0].onsubmit;
if (typeof(ftbSubmit) == 'function')
{
document.forms[0].onsubmit = function()
{
try{ftbSubmit();}
catch(ex){}
}
}
// We are ok
return true;
}
Since my site is an ASP.NET site I also had to add this line in the Page_Load():
ClientScript.RegisterOnSubmitStatement(this.GetType(), String.Concat(this.ClientID, "_OnSubmit"), "javascript: return OvrdSubmit();");
Hope it helps anyone with the same problem.
Firefox has a problem with being inside anything with a style of display:none. What I did was to use a div with a zIndex that hid the div until I needed it displayed. I would start there.
Thanks for your answer, however my problem currently is that the FreeTextBox is inside an AJAX Tab Panel, therefore I would have to reconstruct the whole tab functionality in order to do so, and I do not have adequate time!
For what it's worth, I am close to a solution (I think) by setting the .ReadOnly attribute of the FTB to true and then setting it back to false on the controlo .PreRender. It works for the first time the page loads, so now I have to figure out how to implement this properly for every postback.
I will post the solution if I find it!
Thanks anyway!