Reusable Status QML components
Go to file
Pascal Precht fe67997696
feat(StatusInput): add support for asynchronous validators
This adds support for asynchronous validators which are also just `StatusValidator`.

There are a few differences to syncronous validators though:

1. `validate` function doesn't return, it's only used to trigger the async
   validation. Ideally it would return an async object like Promise or Observable
   but since we have to rely on QML `Connections`, this won't work.
2. As mentioned, `Connections` are needed to listen to async events so the
  validation can be resolved.
3. Validation has to be resolved by calling `input.updateValidity` inside the validator.
   That API notifies `StatusInput` that validation is has been performed and expects
   the name of the validator as well as either a boolean (true), if validation was successful,
   or, if validation has failed, a boolean (false) or an error object.

Here's a `StatusENSValidator` as an example:

```qml
StatusValidator {

    id: root

    name: "ensValidator"
    errorMessage: "Couldn't resolve ENS name."

    readonly property string uuid: Utils.uuid()

    property int debounceTime: 600

    signal ensResolved(string address)

    validate: Backpressure.debounce(root, root.debounceTime, function (name) {
        name = name.startsWith("@") ? name.substring(1) : name
        walletModel.ensView.resolveENS(name, uuid)
    })

    Connections {
        target: walletModel.ensView
        onEnsWasResolved: {
            if (uuid !== root.uuid) {
                return
            }
            root.ensResolved(resolvedAddress)
            input.updateValidityAndPendingState(root.name, resolvedAddress !== "")
        }
    }
}
```

Closes #395
2021-09-16 15:58:00 +10:00
sandbox feat(Spellchecker): Add Spellchecker class 2021-09-14 14:34:25 +02:00
src feat(StatusInput): add support for asynchronous validators 2021-09-16 15:58:00 +10:00
.gitignore fix: Add missing .qml to resources, add qmlcache to gitignore 2021-06-29 09:47:47 +02:00
CHANGELOG.md chore: cut 0.9.0 release 2021-09-13 10:59:02 +02:00
README.md feat(StatusChatListAndCategories): add drag and drop support for cate… (#349) 2021-08-26 15:33:45 -04:00
statusq.qrc feat(StatusExpandableItem): Refactored the StatusExpandableSettingsItem to support different types 2021-09-08 13:37:03 +02:00

README.md

StatusQ

An emerging reusable QML UI component library for Status applications.

Usage

StatusQ introduces a module namespace that semantically groups components so they can be easily imported. These modules are:

Provided components can be viewed and tested in the sandbox application that comes with this repository. Other than that, modules and components can be used as expected.

Example:

import Status.Core 0.1
import Status.Controls 0.1

StatusInput {
  ...
}

Viewing and testing components

To make viewing and testing components easy, we've added a sandbox application to this repository in which StatusQ components are being build. This is the first place where components see the light of the world and can be run in a proper application environment.

Using Qt Creator

The easiest way to run the sandbox application is to simply open the provided sandbox.pro file using Qt Creator.

Using command line interface

To run the sandbox from within a command line interface, run the following commands:

$ git clone https://github.com/status-im/StatusQ
$ cd StatusQ/sandbox
$ ./scripts/build

Once that is done, the sandbox can be started with the generated executable:

$ ./bin/sandbox

More Documentation available on the wiki