GithubHelp home page GithubHelp logo

Comments (2)

pandulapeter avatar pandulapeter commented on May 27, 2024 1

Thanks for the awesome idea!

At first I didn't know how to approach this from the API perspective but now I think I have a good solution. Here are the changes that can be used from version 1.10.0. To summarize:

  • The Slider, Toggle, SingleSelectionList and MultipleSelectionList tricks now contain an optional parameter called 'needsConfirmation' (false by default). If this confirmation is enabled, the usual callback that belongs to the trick (onValueChanged or onItemSelectionChanged) will not be called immediately as before, only after the Apply button that you suggested is pressed.
  • The Apply button appears and disappears dynamically (it's only visible if there are changes to be applied) - the animation and the gradient are work-in-progress...
  • There also is a Reset button which, by default, appeares besides Apply - the Beagle.imprint() function's shouldShowResetButton can be used to hide it.
  • The texts that appear on the button can be changed in the Appearance instance that is provided to Beagle.imprint().
  • If multiple pending changes are waiting to be applied, they will be called one after the other the moment the user presses the Apply button. If you need to perform an action after the last callback is called (like restarting the app), you can check the value of Beagle.hasPendingChanges. Now that I think about it, it might be a good idea to add a separate callback for this in a future version.
  • The demo app has been updated to contain examples for Toggle and SingleSelectionList.

This is very early stuff so it's possible to contain bugs... Please let me know if you find any.

And of course if the API is not suitable for what you had in mind, we'll get back to brainstorming :)

from beagle.

pandulapeter avatar pandulapeter commented on May 27, 2024

I've fixed some issues, added some new features and improved some of the recent things in 1.10.1. With those changes in mind, my suggestion for your specific usecase:

  • For all modules that modify settings needing an app restart to take effect, set the needsConfirmation constructor parameter to true when defining the trick.
  • In the lambdas for these tricks update the value stored in shared preferences, as these callbacks will only get invoked when the user presses "Apply".
  • Set a lamda value for Beagle.onAllChangesApplied where you kill the application process / restart the app / whatever. This is new in v1.10.1 and will get called after the lambdas I mentioned previously.
  • If you'd like to fine-tune the behavior, the Beagle.imprint() function can handle a new, Behavior object besides the old Appearance. The relevant properties:
    • In Appearance: applyButtonText and resetButtonText as mentioned before
    • In Behavior: shouldShowResetPendingChangesButton and shouldResetPendingChangesOnClose. The latter is new: if you set it to true, all pending changes will be reset when the user closes the drawer without pressing "Apply".

from beagle.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.