I am using Foundations Joyride plugin in my web app. What I am trying to achieve is something like where the user can say that never show me again button on each step.
For example I am on the first item their I want two buttons, Next/Don't show again.
Is there a way to get that?
I had this issue and solved it by making a separate popup in the same style which came up to prompt the user to do something else (in this case start a video) or start the joyride.
On this we also included a checkbox called 'never show me this again' and then stored the result in a cookie to make sure the box didn't auto-popup when reloading the page.
The following code should help (you will need to set or clear the 'show_joyride' cookie yourself - we use js.cookie.js):
var showJoyride = Cookies.get('show_joyride');
// Setup joyride but tell it not to auto start
$("#joyRideTipContent").joyride({
autoStart : false,
modal:true,
expose: true
});
if(showJoyride == 'true'){
// Start the joyride
$("#joyRideTipContent").joyride({
modal:true,
expose: true
});
}
Related
I'm new to Jetpack Compose, so I'm struggling to implement a feature which is dynamic colors (and font, size,... but I think they are the same so I'll just focus on color) at run time from backend. I'll let the app the some default colors, and a whole default splash screen just to load the colors setting from the backend. In case the API request failed, it would use the last succeeded requested colors or just the default color.
Tutorials I found round the internet was just about changing the dark/light theme at run time, not changing a specific color in the color pack. In those tutorials, the color is defined in Colors.kt file which is not a composable or class or object, ...
I imagine the color within lightColors or darkColors would be something like this.
return lightColors(
primary = Color(android.graphics.Color.parseColor("#" + dynamicColorMap["One"])),
...
}
And when dynamicColorMap changes in the splashscreen, all screen later will have reference to the new value, but I don't know how to update its variable outside of a composable.
I thought of using DB to store the colors, but getting the data from DB is async, so it cannot be query in the default Colors.kt like var colorOne = DBManager.getColor("One"), I can run the async task in my splash screen before changing to the next screen but then the problem again is how to have a global state that my theme composable wrapper can have access to on every screen?
I just don't know where to start for these case.
Thank you for your time
EDIT:
I currently having the project structured in MVVM. For now, only one activity (MainActivity) is present, and inside that activity, the splash screen component or home screen or login screen,... are being navigated. So is it a good practice to create a viewmodel for the mainactivity screen, that can holds the color state for the theme?
Thanks #Maciej Ciemiega for the suggestion. I ended up structure my code like that.
In my MainActivity.kt I create a viewmodel for it.
val mainActivityViewModel by viewModels<MainActivityViewModel>()
MyTheme(mainActivityViewModel = mainActivityViewModel) {
initNavigationController(navController)
Surface(color = MaterialTheme.colors.background) {
if (mainActivityViewModel.appSettingsState.value.appSettings.colorsMapLight.size != 0
&& mainActivityViewModel.appSettingsState.value.appSettings.colorsMapDark.size != 0) {
navController.navigate(NavigationDestinations.homeScreen)
}
}
}
my initNavigationController function shows the splashscreen first. But it doesn't do anything. The getting app settings configuration is called in MyTheme composable via the mainActivityViewModel, and MyTheme will use the state from the viewmodel to define the theme, and the navController.navigate is based on the state as you guys can see in the if above.
I don't know if this is a good practice or not, or when my app grows it would be a mess or not, but at least it works for me. I tried with font styles too and it works like a charm.
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.
How can I call a function on click of back button in Ionic 2 from a specific page?
I have the following scenario in my mind. Lets say I navigate like below:
PageA --> PageB --> PageC --> PageD
Now when I click back button on PageD I want to go back to PageB instead of PageC. I want to call below function on click of back button.
goBack(){
this.navCtrl.popTo(PageB);
}
I have done it Like this:
ionViewDidEnter(){
this.bindMethodToElement('back-button',this.goBack);
}
bindMethodToElement(elementClassName,functionToBind){
try{
let elements = document.getElementsByClassName(elementClassName);
let currentElement : Element = elements[elements.length - 1];
currentElement.addEventListener("click",functionToBind);
}catch(exception){
console.log(exception.message);
throw exception;
}
}
Does anyone know better approach to do it. I also want to achieve similar behavior when user clicks on the device back button.
Such a feature was already reported to the Ionic team and they are validating it. In the meantime you can use this workaround:
goBack(){
this.navCtrl.pop().then(() => {this.navCtrl.pop()});
}
Ugly solution but works. Good luck!
Titanium SDK version: 1.6.2 (tried with 1.7 too)
iPhone SDK version: 4.2
I am developing an iPhone app and I am fetching data from my API and presenting it in a table. In this table I got a button on each row that should allow the user to add that person to his or her contacts. The only problem with the code (I think) is that only the last button responds when being clicked. Nothing happens when I click the other buttons.
This is my code: http://pastie.org/1932098
What is wrong?
You are adding the button.addEventListener outside of the for statement, and since you are overwriting the button var with each iteration, the eventListener only attaches to the last button created.
This probably isn't the best way to work this, but to fix your problem, move the button.addEventListener inside the for statement, and then check for a unique identifier in the object that gets sent to the event. Example:
for (x=0;x<5;x++) {
var button = Titanium.UI.createButton({
height:40,
width:100,
top:50*x,
id:x
});
var label = Titanium.UI.createLabel({
text:'LABEL '+x
});
button.add(label);
win1.add(button);
button.addEventListener('click', function(e){
Ti.API.info('Button clicked '+e.source.id);
});
}
The button.id property is just made up, but now you can see which button sends the event. You could also use title, or anything else that is unique.
Other options to look at are creating unique variable names for each button, but that's probably more work. Also, instead of working with putting a button in the table row, use a label or image, then listen for the event generated by the table or row.