bixbybixbystudio

Bixby: want to implement stop watch in my capsule


I want to display a stopwatch(timer) for my capsule.

So, is there any way from which I can show timer in my view page which will get refreshed every second. I am not understanding where to start. How will time get refreshed?

Any help on this.


Solution

  • You can use the built-in refresh command to repaint the screen. For example,

    result-view {
      match {
        Activity (this) {
          min (Required)
          max (One)
          from-output: CheckRideShareStatus (check)
        }
      }
      message {
        if (this.countdown != 0) {
          template ("Your ride will arrive in #{value(this.countdown)} seconds.") 
        } else {
          template ("I hope you are enjoying your ride")
        }
      }
      refresh {
      if (this.countdown != 0) {
        spec {
          delay-seconds (5)
          with-request {
            intent {
              goal: CheckRideShareStatus
              value {
                $expr (this)
              }
            }
          }
        }
      }
    }
      render {
        layout-macro (activity-map-macro) {
          param (activity) {
            expression (this)
          }
        }
      }
    }
    

    The Bixby team has provided a working example on Github

    Detail on refresh here