<?xml version="1.0" encoding="UTF-8"?><rss xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:atom="http://www.w3.org/2005/Atom" version="2.0" xmlns:cc="http://cyber.law.harvard.edu/rss/creativeCommonsRssModule.html">
    <channel>
        <title><![CDATA[Stories by Simay Ayberik on Medium]]></title>
        <description><![CDATA[Stories by Simay Ayberik on Medium]]></description>
        <link>https://medium.com/@simayayberik?source=rss-2ef481fd1de8------2</link>
        <image>
            <url>https://cdn-images-1.medium.com/fit/c/150/150/1*KItj20xWIQqgTJph7VsCmg.jpeg</url>
            <title>Stories by Simay Ayberik on Medium</title>
            <link>https://medium.com/@simayayberik?source=rss-2ef481fd1de8------2</link>
        </image>
        <generator>Medium</generator>
        <lastBuildDate>Tue, 17 Nov 2026 22:36:50 GMT</lastBuildDate>
        <atom:link href="https://medium.com/@simayayberik/feed" rel="self" type="application/rss+xml"/>
        <webMaster><![CDATA[yourfriends@medium.com]]></webMaster>
        <atom:link href="http://medium.superfeedr.com/" rel="hub"/>
        <item>
            <title><![CDATA[How to Bind the Digital Crown to UI State on Huawei Lite Wearables]]></title>
            <link>https://medium.com/huawei-developers/how-to-bind-the-digital-crown-to-ui-state-on-huawei-lite-wearables-6ca972e3c9f5?source=rss-2ef481fd1de8------2</link>
            <guid isPermaLink="false">https://medium.com/p/6ca972e3c9f5</guid>
            <category><![CDATA[harmonyos-next]]></category>
            <category><![CDATA[huawei]]></category>
            <category><![CDATA[crown]]></category>
            <category><![CDATA[lite-wearable]]></category>
            <category><![CDATA[wearables]]></category>
            <dc:creator><![CDATA[Simay Ayberik]]></dc:creator>
            <pubDate>Mon, 31 Aug 2026 08:11:29 GMT</pubDate>
            <atom:updated>2026-09-15T05:41:04.521Z</atom:updated>
            <content:encoded><![CDATA[<figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*rneSNwODnBh1je8vasBzRA.png" /><figcaption>Routing Digital Crown input to a UI state with a hidden slider proxy</figcaption></figure><p>Using a hidden slider proxy to bring Digital Crown interaction to custom UI components on Huawei Lite Wearables.</p><h3>Introduction</h3><p>Huawei Lite wearable devices ship with a physical Digital Crown, but the Lite Wearable JS framework has no page-level API for it. There is no onDigitalCrown handler and no crown event monitor to register on a page. Crown input is only exposed through a rotation({ focus }) method, and only on two components: &lt;slider&gt; and &lt;list&gt;.</p><p>That leaves a real gap the moment your UI is not a slider or a list. I ran into this trying to implement value increment/decrement box on a Lite wearable, where crown rotation needed to increment or decrement whichever cell the user had just tapped. There is no &lt;slider&gt; or &lt;list&gt; anywhere in a grid like that, so the crown had nothing to bind to out of the box. This article covers the workaround: a hidden, invisible slider that proxies crown rotation to whatever UI state is currently selected.</p><h3>Why &lt;list&gt; Does Not Work as a Proxy</h3><p>Both &lt;slider&gt; and &lt;list&gt; expose rotation({ focus: boolean }), so it is tempting to reach for &lt;list&gt; if your UI already has one. It does not work as a generic proxy, though. rotation({ focus: true }) is documented to scroll the component only in single-column picker fashion, and for &lt;list&gt; that means the crown drives the list&#39;s own scroll or selection behavior, not an arbitrary numeric value. &lt;slider&gt; is the one component whose onchange event actually surfaces a usable e.value, which is what makes it the right fit here.</p><p>None of this applies if you are targeting the full HarmonyOS ArkUI framework, where onDigitalCrown and setMonitorForCrownEvents exist under SystemCapability.ArkUI.ArkUI.Full. Those APIs are not available on Lite Wearable JS pages, so the proxy pattern below is specific to this environment.</p><h3>Building the Proxy Slider</h3><p>The core idea is a &lt;slider&gt; shrunk to 1x1px and made fully transparent, so it never renders but stays focusable for hardware input:</p><pre>.proxy-slider {<br>  width: 1px;<br>  height: 1px;<br>  opacity: 0;<br>}</pre><pre>&lt;slider<br>    ref=&quot;crownProxy&quot;<br>    class=&quot;proxy-slider&quot;<br>    min=&quot;0&quot; max=&quot;6&quot;<br>    onchange=&quot;handleCrownChange&quot;&gt;<br>&lt;/slider&gt;</pre><p>min and max set the crown&#39;s value ceiling and floor for the whole page. If different UI elements need different ranges, that has to be clamped manually inside the change handler rather than relying on the slider&#39;s own bounds.</p><h3>Giving the Proxy Hardware Focus</h3><p>The proxy only receives crown events while it holds focus, so focus has to be granted on page show and again every time the user selects a different target. Focus does not follow selectedBoxIndex on its own, it has to be re-invoked explicitly:</p><pre>onShow() {<br>    this.enableCrownFocus();<br>},<br>selectBox(index) {<br>    this.selectedBoxIndex = index;<br>    this.enableCrownFocus();<br>},<br>enableCrownFocus() {<br>    if (this.$refs.crownProxy) {<br>        this.$refs.crownProxy.rotation({ focus: true });<br>    }<br>},</pre><blockquote><em>Pro Tip: Always release crown focus on </em><em>onHide and </em><em>onDestroy. If the proxy slider keeps focus after the page is no longer active, it keeps consuming hardware rotation events that the user expects to go elsewhere.</em></blockquote><pre>onHide() {<br>    this.disableCrownFocus();<br>},<br>onDestroy() {<br>    this.disableCrownFocus();<br>},<br>disableCrownFocus() {<br>    if (this.$refs.crownProxy) {<br>        this.$refs.crownProxy.rotation({ focus: false });<br>    }<br>}</pre><h3>Routing the Value to Selected State</h3><p>The proxy slider itself holds no visible value, it is purely a router. selectedBoxIndex tracks which cell is active, and handleCrownChange writes the incoming value to that cell:</p><pre>data: {<br>    valueBox0: 0,<br>    valueBox1: 0,<br>    selectedBoxIndex: -1<br>},<br>handleCrownChange(e) {<br>    if (this.selectedBoxIndex === 0) {<br>        this.valueBox0 = e.value;<br>    } else if (this.selectedBoxIndex === 1) {<br>        this.valueBox1 = e.value;<br>    }<br>},</pre><p>The UI reflects which cell is selected by border color, and shows nothing when the value is 0, treating that as an empty cell:</p><pre>&lt;div class=&quot;cell&quot;<br>     style=&quot;border-color: {{ selectedBoxIndex === 0 ? &#39;#007DFF&#39; : &#39;#FFFFFF&#39; }};&quot;<br>     onclick=&quot;selectBox(0)&quot;&gt;<br>    &lt;text class=&quot;cell-text&quot;&gt;{{ valueBox0 === 0 ? &#39;&#39; : valueBox0 }}&lt;/text&gt;<br>&lt;/div&gt;</pre><h3>Putting It Together</h3><p>Here is the full page with two cells, matching the screenshots below. Lite Wearable JS pages are split into a template, a stylesheet, and a script file, so this drops in as three files: index.hml, index.css, index.js.</p><p>index.hml</p><pre>&lt;div class=&quot;container&quot;&gt;<br>    &lt;text class=&quot;title&quot;&gt;Select Box&lt;/text&gt;  <br>  &lt;div class=&quot;grid&quot;&gt;<br>        &lt;div class=&quot;cell&quot;<br>             style=&quot;border-color: {{ selectedBoxIndex === 0 ? &#39;#007DFF&#39; : &#39;#FFFFFF&#39; }};&quot;<br>             onclick=&quot;selectBox(0)&quot;&gt;<br>            &lt;text class=&quot;cell-text&quot;&gt;{{ valueBox0 === 0 ? &#39;&#39; : valueBox0 }}&lt;/text&gt;<br>        &lt;/div&gt;<br>        &lt;div class=&quot;cell&quot;<br>             style=&quot;border-color: {{ selectedBoxIndex === 1 ? &#39;#007DFF&#39; : &#39;#FFFFFF&#39; }};&quot;<br>             onclick=&quot;selectBox(1)&quot;&gt;<br>            &lt;text class=&quot;cell-text&quot;&gt;{{ valueBox1 === 0 ? &#39;&#39; : valueBox1 }}&lt;/text&gt;<br>        &lt;/div&gt;<br>    &lt;/div&gt;<br>    &lt;text class=&quot;hint&quot;&gt;Rotate Crown to change value&lt;/text&gt;<br>    &lt;slider<br>        ref=&quot;crownProxy&quot;<br>        class=&quot;proxy-slider&quot;<br>        min=&quot;0&quot; max=&quot;9&quot;<br>        onchange=&quot;handleCrownChange&quot;&gt;<br>    &lt;/slider&gt;<br>&lt;/div&gt;</pre><p>index.css</p><pre>.container {<br>    flex-direction: column;<br>    align-items: center;<br>    justify-content: center;<br>}<br>.title {<br>    color: #34C759;<br>    font-size: 32px;<br>    margin-bottom: 20px;<br>}<br>.grid {<br>    flex-direction: row;<br>}<br>.cell {<br>    width: 120px;<br>    height: 120px;<br>    border-width: 2px;<br>    border-radius: 12px;<br>    justify-content: center;<br>    align-items: center;<br>    margin: 0 10px;<br>}<br>.cell-text {<br>    color: #FFFFFF;<br>    font-size: 40px;<br>}<br>.hint {<br>    color: #999999;<br>    font-size: 20px;<br>    margin-top: 20px;<br>}<br>.proxy-slider {<br>    width: 1px;<br>    height: 1px;<br>    opacity: 0;<br>}</pre><p>index.js</p><pre>export default {<br>    data: {<br>        valueBox0: 0,<br>        valueBox1: 0,<br>        selectedBoxIndex: -1<br>    },<br>    onShow() {<br>        this.enableCrownFocus();<br>    },<br>    onHide() {<br>        this.disableCrownFocus();<br>    },<br>    onDestroy() {<br>        this.disableCrownFocus();<br>    },<br>    selectBox(index) {<br>        this.selectedBoxIndex = index;<br>        this.enableCrownFocus();<br>    },<br>    enableCrownFocus() {<br>        if (this.$refs.crownProxy) {<br>            this.$refs.crownProxy.rotation({ focus: true });<br>        }<br>    },<br>    disableCrownFocus() {<br>        if (this.$refs.crownProxy) {<br>            this.$refs.crownProxy.rotation({ focus: false });<br>        }<br>    },<br>    handleCrownChange(e) {<br>        if (this.selectedBoxIndex === 0) {<br>            this.valueBox0 = e.value;<br>        } else if (this.selectedBoxIndex === 1) {<br>            this.valueBox1 = e.value;<br>        }<br>    }<br>}</pre><h3>Output</h3><figure><img alt="" src="https://cdn-images-1.medium.com/max/971/1*ZQm2bDFq4pIALuePemxTyA.png" /><figcaption>the three-watch progression showing an empty grid, one cell filled after crown rotation, and both cells filled</figcaption></figure><p>The sequence above shows the pattern end to end: an empty two-cell grid, the first cell selected and set to 1 by rotating the crown, then both cells filled after selecting and rotating on the second. The blue border marks whichever cell currently holds crown focus, so the user always knows what the next rotation will affect.</p><h3>Limitations to Consider</h3><ul><li>The crown cannot bind directly to a non-slider component. A hidden &lt;slider&gt; proxy is required as the rotation event source for arbitrary numeric state.</li><li>&lt;list&gt; also exposes rotation({ focus }), but it drives the list&#39;s own scroll/selection behavior rather than emitting a generic value, so it cannot substitute for the proxy slider.</li><li>min/max on the proxy slider apply globally to the page. Per-element ranges need manual clamping inside the change handler.</li><li>rotation({ focus: true }) must be called again every time the selected target changes, it does not follow selectedBoxIndex automatically.</li><li>This pattern is specific to the Lite Wearable JS framework. It does not apply to the ArkTS/ArkUI onDigitalCrown or setMonitorForCrownEvents APIs, which require SystemCapability.ArkUI.ArkUI.Full and target full HarmonyOS wearables, not Lite Wearable JS pages.</li></ul><h3>Conclusion</h3><p>Binding the Digital Crown to arbitrary UI state on Lite wearables is indirect by design. There is no native per-component crown listener outside of &lt;slider&gt; and &lt;list&gt;, so a hidden proxy slider paired with explicit focus management and a routing layer is the practical way to get crown input into any element that is not natively crown-aware. It takes a bit more bookkeeping than a direct event handler would, but it holds up well once the focus and routing logic are in place.</p><h3>References</h3><ul><li><a href="https://github.com/Explore-In-HMOS-Wearable/sportwatch-how-to-use-crown">How to Use Crown Codelab (GitHub)</a></li><li><a href="https://developer.huawei.com/consumer/en/doc/harmonyos-guides/ui-js-components-slider">slider Component (API Reference — rotation({ focus }) method)</a></li><li><a href="https://developer.huawei.com/consumer/en/doc/harmonyos-guides/ui-js-components-list">list Component (API Reference — rotation/scrollTo methods)</a></li></ul><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=6ca972e3c9f5" width="1" height="1" alt=""><hr><p><a href="https://medium.com/huawei-developers/how-to-bind-the-digital-crown-to-ui-state-on-huawei-lite-wearables-6ca972e3c9f5">How to Bind the Digital Crown to UI State on Huawei Lite Wearables</a> was originally published in <a href="https://medium.com/huawei-developers">Huawei Developers</a> on Medium, where people are continuing the conversation by highlighting and responding to this story.</p>]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[How to Group Nearby POIs Into Tap-able Cluster Markers on HarmonyOS Wearables]]></title>
            <link>https://medium.com/huawei-developers/how-to-group-nearby-pois-into-tap-able-cluster-markers-on-harmonyos-wearables-4b9dc6691ee8?source=rss-2ef481fd1de8------2</link>
            <guid isPermaLink="false">https://medium.com/p/4b9dc6691ee8</guid>
            <category><![CDATA[huawei]]></category>
            <category><![CDATA[mapkit]]></category>
            <category><![CDATA[harmonyos-next]]></category>
            <category><![CDATA[wearables]]></category>
            <category><![CDATA[ark-ts]]></category>
            <dc:creator><![CDATA[Simay Ayberik]]></dc:creator>
            <pubDate>Tue, 11 Aug 2026 13:21:47 GMT</pubDate>
            <atom:updated>2026-08-20T05:53:15.974Z</atom:updated>
            <content:encoded><![CDATA[<p>Learn how to use Map Kit’s ClusterOverlay to group nearby POIs into tap-able cluster markers on HarmonyOS wearable screens.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*038_XKgVLSNZEaKaZKzN6w.png" /><figcaption>POI clustering with ClusterOverlay on a HarmonyOS wearable map</figcaption></figure><h3>Introduction</h3><p>POI-heavy map screens are common on HarmonyOS wearable apps, and they come with a real layout problem. Once you plot actual POI data, 10 to 30 points is normal even for a single neighborhood, and at low zoom levels those points overlap each other on screen. A 1.5 inch wearable display does not have room to space pins apart or shrink icons any further, so the map ends up as a pile of stacked markers with no way for the user to tell how many POIs are actually behind them.</p><p>Map Kit (@kit.MapKit) solves this with ClusterOverlay. It groups markers by screen-pixel proximity, merges them into a single cluster marker when zoomed out, and splits them apart automatically as the user zooms in, no manual re-aggregation logic required on the app side. In this article I will walk through how I set it up, how I read the tap events to report the POI count behind each cluster.</p><h3>What ClusterOverlay Actually Does</h3><p>Before touching code, it helps to know the four pieces involved:</p><ul><li>mapCommon.ClusterItem is just a wrapper around a position: LatLng, one per POI.</li><li>mapCommon.ClusterOverlayParams takes a distance (the merge threshold in screen pixels) and the full list of clusterItems.</li><li>map.ClusterOverlay is what addClusterOverlay() returns. It exposes a markerClusterClick event.</li><li>map.MarkerClusterInfo is delivered on every cluster tap. It carries clusterItems (the POIs grouped under that cluster) and marker (the visual marker representing the cluster).</li></ul><p>Minimum API version is 5.0.0 (12), so check your compatibleSdkVersion before wiring this in.</p><h3>Setting Up the Overlay</h3><p>The overlay has to be added after the map has actually loaded, in the same place you would register any other overlay:</p><pre>private async setupClusterOverlay(): Promise&lt;void&gt; {<br>  const params: mapCommon.ClusterOverlayParams = {<br>    distance: CLUSTER_DISTANCE,<br>    clusterItems: MOCK_CLUSTER_ITEMS,<br>  };<br>  try {<br>    this.clusterOverlay = await this.mapController?.addClusterOverlay(params);<br>  } catch (e) {<br>    console.error(&#39;[POIClusterMap] addClusterOverlay failed:&#39;, e.message);<br>    return;<br>  }<br>  // register markerClusterClick here<br>}</pre><p>distance is the part worth experimenting with. On a wearable screen I found values around 80px group aggressively enough to keep the map readable without merging POIs that are genuinely a few streets apart.</p><h3>Reading the Tap: markerClusterClick</h3><p>Once a cluster exists, tapping it fires markerClusterClick with a MarkerClusterInfo payload. This is where you find out how many POIs are actually behind that one dot, and it is also a convenient moment to recenter the camera on the cluster:</p><pre>this.clusterOverlay?.on(&#39;markerClusterClick&#39;, (info: map.MarkerClusterInfo) =&gt; {<br>  const count: number = info.clusterItems.length;<br>  const delegateMarker: map.Marker = info.marker;<br>  delegateMarker.setTitle(`${count} spots`);<br><br>const center: mapCommon.LatLng = delegateMarker.getPosition();<br>  const camPos: mapCommon.CameraPosition = {<br>    target: center,<br>    zoom: this.mapController?.getCameraPosition().zoom ?? MAP_INITIAL_ZOOM,<br>  };<br>  this.mapController?.animateCamera(map.newCameraPosition(camPos), 400);<br>});</pre><p>info.clusterItems.length is the whole trick. No manual counting, no re-running your own spatial math, the engine already did the grouping and just hands you the result.</p><h3>Rendering a Custom Info Window</h3><p>The default info bubble is not going to say “6 spots” on its own, so MarkerDelegate is what lets you draw your own window whenever the engine needs to render one for a cluster marker:</p><pre>@Builder<br>customInfoWindowBuilder($$: map.MarkerDelegate) {<br>  if ($$.marker) {<br>    Column() {<br>      Text($$.marker.getTitle())<br>        .fontSize(13)<br>        .fontWeight(FontWeight.Bold)<br>    }<br>    .padding({ top: 6, bottom: 6, left: 10, right: 10 })<br>    .backgroundColor($r(&#39;app.color.color_info_panel_bg&#39;))<br>    .borderRadius(8)<br>  }<br>}</pre><p>Wire it into MapComponent as the customInfoWindow builder param:</p><pre>MapComponent({<br>  mapOptions: this.mapOptions,<br>  mapCallback: this.mapCallback,<br>  customInfoWindow: this.customInfoWindowBuilder,<br>})</pre><h3>Putting It Together</h3><p>Here is a trimmed, self-contained page that only demonstrates ClusterOverlay and MarkerDelegate, meant to be dropped into a fresh ArkTS wearable project:</p><pre>import { MapComponent, mapCommon, map } from &#39;@kit.MapKit&#39;;<br>import { AsyncCallback } from &#39;@kit.BasicServicesKit&#39;;<br>import { MOCK_CLUSTER_ITEMS, MAP_CENTER, MAP_INITIAL_ZOOM, CLUSTER_DISTANCE } from &#39;../model/MockClusterData&#39;;<br><br>@Entry<br>@Component<br>struct ClusterDemo {<br>  private mapOptions?: mapCommon.MapOptions;<br>  private mapCallback?: AsyncCallback&lt;map.MapComponentController&gt;;<br>  private mapController?: map.MapComponentController;<br>  private mapEventManager?: map.MapEventManager;<br>  private clusterOverlay?: map.ClusterOverlay;<br>  @State private showClusterPanel: boolean = false;<br>  @State private infoClusterCount: number = 0;<br>  aboutToAppear(): void {<br>    this.mapOptions = {<br>      position: { target: MAP_CENTER, zoom: MAP_INITIAL_ZOOM },<br>      zoomGesturesEnabled: true,<br>      scrollGesturesEnabled: true,<br>    };<br>    this.mapCallback = async (err, controller) =&gt; {<br>      if (err) {<br>        console.error(&#39;[ClusterDemo] Map init error:&#39;, err.message);<br>        return;<br>      }<br>      this.mapController = controller;<br>      this.mapEventManager = this.mapController.getEventManager();<br>      this.mapEventManager.on(&#39;mapLoad&#39;, async () =&gt; {<br>        await this.setupClusterOverlay();<br>      });<br>    };<br>  }<br>  onPageShow(): void {<br>    this.mapController?.show();<br>  }<br>  onPageHide(): void {<br>    this.mapController?.hide();<br>  }<br>  private async setupClusterOverlay(): Promise&lt;void&gt; {<br>    const params: mapCommon.ClusterOverlayParams = {<br>      distance: CLUSTER_DISTANCE,<br>      clusterItems: MOCK_CLUSTER_ITEMS,<br>    };<br>    try {<br>      this.clusterOverlay = await this.mapController?.addClusterOverlay(params);<br>    } catch (e) {<br>      console.error(&#39;[ClusterDemo] addClusterOverlay failed:&#39;, e.message);<br>      return;<br>    }<br>    this.clusterOverlay?.on(&#39;markerClusterClick&#39;, (info: map.MarkerClusterInfo) =&gt; {<br>      const count: number = info.clusterItems.length;<br>      const delegateMarker: map.Marker = info.marker;<br>      delegateMarker.setTitle(`${count} spots`);<br>      const center: mapCommon.LatLng = delegateMarker.getPosition();<br>      const camPos: mapCommon.CameraPosition = {<br>        target: center,<br>        zoom: this.mapController?.getCameraPosition().zoom ?? MAP_INITIAL_ZOOM,<br>      };<br>      this.mapController?.animateCamera(map.newCameraPosition(camPos), 400);<br>      this.infoClusterCount = count;<br>      this.showClusterPanel = true;<br>    });<br>  }<br>  @Builder<br>  customInfoWindowBuilder($$: map.MarkerDelegate) {<br>    if ($$.marker) {<br>      Column() {<br>        Text($$.marker.getTitle())<br>          .fontSize(13)<br>          .fontWeight(FontWeight.Bold)<br>      }<br>      .padding({ top: 6, bottom: 6, left: 10, right: 10 })<br>      .backgroundColor(Color.White)<br>      .borderRadius(8)<br>    }<br>  }<br>  build() {<br>    Stack({ alignContent: Alignment.Bottom }) {<br>      MapComponent({<br>        mapOptions: this.mapOptions,<br>        mapCallback: this.mapCallback,<br>        customInfoWindow: this.customInfoWindowBuilder,<br>      })<br>        .width(&#39;100%&#39;)<br>        .height(&#39;100%&#39;)<br>      // MapComponent is a native XComponent, taps on it never reach ArkUI&#39;s<br>      // onClick. A transparent overlay catches the dismiss tap instead.<br>      if (this.showClusterPanel) {<br>        Column()<br>          .width(&#39;100%&#39;)<br>          .height(&#39;100%&#39;)<br>          .backgroundColor(Color.Transparent)<br>          .onClick(() =&gt; { this.showClusterPanel = false; })<br>      }<br>      if (this.showClusterPanel) {<br>        Column() {<br>          Text(&#39;Cluster Info&#39;).fontSize(13).fontWeight(FontWeight.Bold)<br>          Row({ space: 4 }) {<br>            Text(this.infoClusterCount.toString()).fontSize(12)<br>            Text(&#39;spots in this cluster&#39;).fontSize(12)<br>          }<br>        }<br>        .padding(10)<br>        .backgroundColor(&#39;#CC000000&#39;)<br>        .borderRadius(12)<br>        .margin({ bottom: 24 })<br>      }<br>    }<br>    .width(&#39;100%&#39;)<br>    .height(&#39;100%&#39;)<br>  }<br>}</pre><p>And the companion mock data file, trimmed to a few representative points, swap these for your own coordinates:</p><pre>import { mapCommon } from &#39;@kit.MapKit&#39;;<br><br>export const MAP_CENTER: mapCommon.LatLng = { latitude: 41.0082, longitude: 28.9784 };<br>export const MAP_INITIAL_ZOOM: number = 11;<br>export const CLUSTER_DISTANCE: number = 80;<br>export const MOCK_CLUSTER_ITEMS: Array&lt;mapCommon.ClusterItem&gt; = [<br>  { position: { latitude: 41.0369, longitude: 28.9850 } },<br>  { position: { latitude: 41.0138, longitude: 28.9550 } },<br>  { position: { latitude: 41.0451, longitude: 29.0094 } },<br>  { position: { latitude: 41.0117, longitude: 29.0283 } },<br>  { position: { latitude: 41.0482, longitude: 28.9231 } },<br>/*<br>     .<br>     .   more cluster items<br>     .<br>     .<br>   */<br>];</pre><h3>Output</h3><figure><img alt="" src="https://cdn-images-1.medium.com/max/837/1*VGETTrgNi_fZirvEY5dIfQ.png" /><figcaption>POI’s with cluster overlays</figcaption></figure><p>Tapping the cluster animates the camera toward it and pops the custom info window with the live count, no flicker, no leftover pins from the previous zoom level.</p><h3>Limitations to Consider</h3><ul><li>ClusterOverlay and MarkerClusterInfo require minimum API version 5.0.0 (12).</li><li>The x86 wearable emulator does not support watches at all, per the official Map Kit documentation. Test this on a real Huawei Watch device or an Arm-based emulator, an x86 wearable emulator will not run the overlay.</li><li>Verified working on Huawei Watch 5.</li></ul><h3>Conclusion</h3><p>ClusterOverlay is the right tool any time a wearable screen needs to show a moderate number of POIs, tens rather than hundreds, that should group at low zoom and separate as the user zooms in. Pair it with MarkerDelegate and a customInfoWindow builder for cluster-specific UI, and lean on the map engine&#39;s built-in pinch-zoom handling instead of writing your own gesture recognizer to drive re-clustering. It is one of those APIs that does exactly what it promises and gets out of the way.</p><p>If you are working on POI-heavy wearable screens, I would be curious to hear what merge distance you land on for your own UI, it seems to vary a lot by icon size and screen density.</p><h3>References</h3><ul><li><a href="https://developer.huawei.com/consumer/en/doc/harmonyos-guides/map-kit-guide">Aggregating Markers (Guide)</a></li><li><a href="https://developer.huawei.com/consumer/en/doc/harmonyos-references">ClusterOverlay (API Reference)</a></li><li><a href="https://developer.huawei.com/consumer/en/doc/harmonyos-references">MarkerClusterInfo (API Reference)</a></li><li><a href="https://developer.huawei.com/consumer/en/doc/harmonyos-guides/map-kit-guide">Supported Countries/Regions (Map Kit)</a></li></ul><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=4b9dc6691ee8" width="1" height="1" alt=""><hr><p><a href="https://medium.com/huawei-developers/how-to-group-nearby-pois-into-tap-able-cluster-markers-on-harmonyos-wearables-4b9dc6691ee8">How to Group Nearby POIs Into Tap-able Cluster Markers on HarmonyOS Wearables</a> was originally published in <a href="https://medium.com/huawei-developers">Huawei Developers</a> on Medium, where people are continuing the conversation by highlighting and responding to this story.</p>]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Long Press & Drag-to-Reorder in ArkUI: Dynamic List Manipulation]]></title>
            <link>https://medium.com/huawei-developers/long-press-drag-to-reorder-in-arkui-dynamic-list-manipulation-dab26f87cd37?source=rss-2ef481fd1de8------2</link>
            <guid isPermaLink="false">https://medium.com/p/dab26f87cd37</guid>
            <category><![CDATA[huawei-developers]]></category>
            <category><![CDATA[ark-ui]]></category>
            <category><![CDATA[harmonyos-next]]></category>
            <category><![CDATA[reorderable-listview]]></category>
            <category><![CDATA[dynamic-list]]></category>
            <dc:creator><![CDATA[Simay Ayberik]]></dc:creator>
            <pubDate>Thu, 31 Jul 2025 08:47:30 GMT</pubDate>
            <atom:updated>2025-07-31T08:47:30.502Z</atom:updated>
            <content:encoded><![CDATA[<figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*MQRYvdwcgqyTjJTo9phr5A.png" /><figcaption>Cover Image(ChatGPT Generated)</figcaption></figure><h3>Introduction</h3><p>User-friendly interfaces often depend on the little details like how easy it is to move items in a list. In HarmonyOS NEXT apps, enabling drag-to-reorder interactions can enhance usability. Think of playlist editors, task organizers, or customized settings lists.</p><p>ArkUI, the declarative UI framework for HarmonyOS, provides everything needed to implement this interaction cleanly: gesture sequencing, visual feedback, and efficient rendering. In this article, we’ll explore how to create a smooth long-press and drag-to-reorder experience using ArkUI and ArkTS.</p><h3>We use several functions like;</h3><ul><li>LongPressGesture to activate drag mode</li><li>PanGesture to track movement</li><li>GestureGroup for sequencing gestures</li><li>animateTo() for smooth visual transitions</li></ul><p>The combination offers high responsiveness with minimal performance cost.</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/f9432ef23226b563d07b6098bc30de5c/href">https://medium.com/media/f9432ef23226b563d07b6098bc30de5c/href</a></iframe><h4><strong>LongPressGesture and PanGesture</strong></h4><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/1acd5279bee99604a146b6c35ca3bc37/href">https://medium.com/media/1acd5279bee99604a146b6c35ca3bc37/href</a></iframe><p>When long-pressing:</p><p>The animation starts.</p><p>The element is activated by slightly enlarging it with Curve. Friction (e.g., scale = 1.05).</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/d3f0aa50ada914665e0c228524d12898/href">https://medium.com/media/d3f0aa50ada914665e0c228524d12898/href</a></iframe><p>When dragging begins:</p><p>The dragged item (dragItem) is recorded.</p><p>The drag offset is reset (dragRefOffset = 0).</p><h4>Position Swapping Logic</h4><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/a48a920d006ede82b62d5b1f9c8115f1/href">https://medium.com/media/a48a920d006ede82b62d5b1f9c8115f1/href</a></iframe><p>If the drag distance (offsetY) is greater than half an element’s height (e.g., more than half an element has been dragged):</p><p>Displacement is initiated.</p><p>The animateTo function is called with an interpolating spring animation:</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/24a85a1cbef60b3d49a97423ba5d8c4b/href">https://medium.com/media/24a85a1cbef60b3d49a97423ba5d8c4b/href</a></iframe><p>Here:</p><p>-400 = spring stiffness</p><p>38 = damping</p><p>offsetY is updated by an entire item height in that swap direction:</p><p>offsetY =± 𝐼𝑇𝐸𝑀_𝐼𝑁𝑇𝑉<br><br>dragRefOffset is updated in the same way.</p><p>The itemMove function is called:</p><p>itemMove(currentIndex, newIndex)<br><br>This function swaps the locations of items in the data model.</p><p>👉 Mathematical meaning:</p><p>If:</p><p>∣offsetY∣ &gt; ITEM_INTV / 2<br>​<br>then, the items are swapped.</p><p>Math.sign(this.offsetY) determines the swap direction: up or down.</p><h3>Why use interpolating springs for swapping?</h3><p>Makes the UI feel responsive and natural<br> Prevents jarring “jumping” of items<br> Gives visual feedback of the new position<br> Mimics real-world physics, improving perceived quality</p><h3>Output:</h3><figure><img alt="" src="https://cdn-images-1.medium.com/max/274/1*QofaP23kCoBFOaIu_U5C-w.gif" /><figcaption>Draggable List Items</figcaption></figure><h3>Core Functionality</h3><p>This solution enables:</p><ul><li>Long-pressing a list item to enter drag mode</li><li>Dragging the item vertically with dynamic scaling and shadow feedback</li><li>Automatic <strong>position swapping</strong> based on drag distance</li><li>Smooth release animation and state reset</li></ul><h3>Conclusion</h3><p>Implementing intuitive, animated list interactions in HarmonyOS NEXT is no longer a complex task. With ArkUI’s gesture system and animation tools, you can create highly responsive and visually dynamic list behaviors like drag-to-reorder with minimal code and maximum performance. By combining long press and pan gestures through GestureGroup, then wrapping UI changes with animateTo(), developers can deliver fluid, delightful UX for everyday use cases. This approach balances performance, code simplicity, and user satisfaction—making it a powerful pattern to adopt in any ArkTS-based application.</p><h3>References</h3><ul><li><a href="https://developer.huawei.com/consumer/en/doc/harmonyos-guides-V13/arkts-common-events-drag-event-V13">Document</a></li><li><a href="https://developer.huawei.com/consumer/en/doc/harmonyos-guides-V13/arkts-gesture-events-binding-V13">Document</a></li></ul><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=dab26f87cd37" width="1" height="1" alt=""><hr><p><a href="https://medium.com/huawei-developers/long-press-drag-to-reorder-in-arkui-dynamic-list-manipulation-dab26f87cd37">Long Press &amp; Drag-to-Reorder in ArkUI: Dynamic List Manipulation</a> was originally published in <a href="https://medium.com/huawei-developers">Huawei Developers</a> on Medium, where people are continuing the conversation by highlighting and responding to this story.</p>]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[State Management Showdown: Flutter vs Compose vs React Native vs SwiftUI vs ArkUI in 2025]]></title>
            <link>https://medium.com/huawei-developers/state-management-showdown-flutter-vs-compose-vs-react-native-vs-swiftui-vs-arkui-in-2025-00174e545e31?source=rss-2ef481fd1de8------2</link>
            <guid isPermaLink="false">https://medium.com/p/00174e545e31</guid>
            <category><![CDATA[flutter]]></category>
            <category><![CDATA[ark-ui]]></category>
            <category><![CDATA[state-management]]></category>
            <category><![CDATA[harmonyos-next]]></category>
            <category><![CDATA[ark-ts]]></category>
            <dc:creator><![CDATA[Simay Ayberik]]></dc:creator>
            <pubDate>Sun, 08 Jun 2025 08:52:34 GMT</pubDate>
            <atom:updated>2025-06-20T13:40:34.436Z</atom:updated>
            <content:encoded><![CDATA[<figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*Y4Hc526CRWF51XtvPLEPFQ.png" /><figcaption>State Managements for Frameworks</figcaption></figure><h3><strong>📌 Introduction</strong></h3><p>In today’s fast-paced mobile development world, building responsive, scalable, and maintainable apps is no longer a luxury — it’s a necessity. Whether you’re creating apps with Flutter, Jetpack Compose, React Native, SwiftUI, or the newer ArkUI (ArkTS) for HarmonyOS, state management is at the heart of the user experience.</p><p>Each framework offers its own approach to handling state — some are simple and local, while others embrace more reactive, global solutions. With increasing demand for cross-platform consistency and native performance, understanding how state management works across these ecosystems is more important than ever.</p><p>In this article, we’ll explore and compare the core state management techniques of five major UI frameworks. We’ll look at syntax, tooling, performance, scalability, and real-world use cases — so you can choose the right approach for your next mobile project.</p><h4><strong>❓ What is State Management?</strong></h4><p><strong>State</strong> refers to the data that determines the UI’s current condition — like whether a button is clicked, a list is loaded, or a user is authenticated.</p><p><strong>State management</strong> is how an app tracks, updates, and responds to changes in that data. In modern declarative frameworks, UI is a reflection of the state. When state changes, the UI automatically updates to reflect the new conditions.</p><p>Here’s a basic cycle in declarative UI frameworks:</p><p>User Interaction → State Change → UI Recomposition → New UI Rendered</p><p>Managing state efficiently is essential for:</p><ul><li>Keeping UI reactive and consistent</li><li>Avoiding unnecessary renders</li><li>Making code modular and maintainable</li><li>Supporting complex workflows like login, shopping carts, or animations</li></ul><p>🧠 <strong>Tip:</strong> Good state management minimizes bugs, improves performance, and makes debugging easier — especially in large applications.</p><h4>📊 State Management Comparison Table</h4><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*MuD70ZtmQxFP5oqDNSwcxw.png" /><figcaption>State Management Comparison Table Flutter, Compose, React Native, ArkUI(ArkTS)</figcaption></figure><p>📌 ArkUI is HarmonyOS’s declarative UI framework, inspired by SwiftUI, and built using ArkTS (a superset of TypeScript for HarmonyOS).</p><h4>🔍 Deep Dive: State Management by Framework</h4><h4>🟣 <strong>Flutter</strong></h4><p>Flutter is Google’s UI toolkit for building natively compiled apps from a single codebase using the Dart language.</p><p><strong>✅ State Management Options:</strong></p><p>· setState for local UI updates</p><p>· Provider, Riverpod, Bloc, Cubit for scalable and reactive global state</p><p>· Reactive updates automatically trigger UI rebuilds</p><p>🧪<strong> Example — </strong><strong>Riverpod Counter:</strong></p><pre>final counterProvider = StateProvider&lt;int&gt;((ref) =&gt; 0);<br><br>Consumer(<br>  builder: (context, ref, _) {<br>    final count = ref.watch(counterProvider);<br>    return Column(<br>      children: [<br>        Text(&#39;Count: $count&#39;),<br>        ElevatedButton(<br>          onPressed: () =&gt; ref.read(counterProvider.notifier).state++,<br>          child: Text(&#39;Increase&#39;),<br>        ),<br>      ],<br>    );<br>  },<br>);</pre><p>✅ <strong>Pros:</strong></p><p>· High performance across platforms</p><p>· Rich package ecosystem</p><p>· Strong community and documentation</p><p>❌<strong> Cons:</strong></p><p>· Can become verbose in larger apps</p><p>· setState gets harder to manage at scale</p><h4><strong>🔵 Jetpack Compose</strong></h4><p>Jetpack Compose is Android’s modern declarative UI toolkit, tightly integrated with Kotlin and modern Android APIs.</p><p><strong>✅ State Management Options:</strong></p><p>· remember, mutableStateOf, derivedStateOf</p><p>· Integrates well with StateFlow and LiveData</p><p>🧪 <strong>Example</strong>:</p><pre>var count by remember { mutableStateOf(0) }<br><br>Column {<br>    Text(&quot;Count: $count&quot;)<br>    Button(onClick = { count++ }) {<br>        Text(&quot;Increase&quot;)<br>    }<br>}</pre><p>✅ <strong>Pros</strong>:</p><p>· Seamless Kotlin integration</p><p>· Efficient recomposition via the Compose compiler</p><p>· Coroutines and Flow support make it modern and reactive</p><p>❌ <strong>Cons</strong>:</p><p>· Android-only</p><p>· More complex apps require careful state structuring</p><h4>🔷 React Native</h4><p>React Native lets you build mobile apps using JavaScript or TypeScript, bringing the flexibility of web development to mobile.</p><p><strong>✅ State Management Options:</strong></p><p>· useState, useReducer for local state</p><p>· Redux, Zustand, Jotai, Recoil for global state</p><p>🧪 <strong>Example — </strong><strong>useState Counter:</strong></p><pre>const [count, setCount] = useState(0);<br><br>return (<br>  &lt;View&gt;<br>    &lt;Text&gt;Count: {count}&lt;/Text&gt;<br>    &lt;Button title=&quot;Increase&quot; onPress={() =&gt; setCount(count + 1)} /&gt;<br>  &lt;/View&gt;<br>);</pre><p>✅ <strong>Pros:</strong></p><p>· Familiar to frontend/web developers</p><p>· Huge JS/TS ecosystem</p><p>· Fast development with hot reload</p><p>❌ <strong>Cons:</strong></p><p>· Performance bottlenecks due to JS/native bridge</p><p>· State can get messy in large apps</p><h4>🍏 SwiftUI</h4><p>SwiftUI is Apple’s declarative UI framework, available on iOS, macOS, watchOS, and tvOS.</p><p>✅ <strong>State Management Options:</strong></p><p>· @State, @ObservedObject, @EnvironmentObject, @StateObject</p><p>🧪 <strong>Example:</strong></p><pre>struct CounterView: View {<br>    @State private var count = 0<br><br>    var body: some View {<br>        VStack {<br>            Text(&quot;Count: \(count)&quot;)<br>            Button(&quot;Increase&quot;) {<br>                count += 1<br>            }<br>        }<br>    }<br>}</pre><p>✅ <strong>Pros:</strong></p><p>· Native performance on Apple devices</p><p>· Clean and concise declarative syntax</p><p>· Combine support for reactive streams</p><p>❌ <strong>Cons:</strong></p><p>· Apple-only</p><p>· Can be challenging for complex UI logic or animations</p><h4>🟠 ArkUI (ArkTS) — HarmonyOS NEXT</h4><p>ArkUI is Huawei’s modern UI framework built specifically for HarmonyOS NEXT, using a TypeScript-inspired language called <strong>ArkTS</strong>. It offers a highly performant, fully declarative approach inspired by SwiftUI but designed with distributed device scenarios in mind.</p><p>✅ <strong>State Management Options:</strong></p><p>· @State: Local state</p><p>· @Provide, @Consume: Dependency injection for shared/global state</p><p>· @Link: Two-way binding</p><p>· @Watch: Reactive side effects</p><p>🧪 <strong>Example — </strong><strong>@State Counter:</strong></p><pre>@Entry<br>@Component<br>struct CounterComponent {<br>  @State count: number = 0;<br><br>  build() {<br>    Column() {<br>      Text(`Count: ${this.count}`)<br>      Button(&quot;Increase&quot;)<br>        .onClick(() =&gt; {<br>          this.count += 1;<br>        })<br>    }<br>  }<br>}</pre><h4>🌟 ArkUI / HarmonyOS NEXT: Standout Advantages</h4><p>· 🔥 <strong>True Native Performance (No Bridge)</strong><br> Unlike React Native, ArkUI doesn’t rely on a JS/native bridge — ensuring smooth animations, faster render times, and efficient memory usage.</p><p>· ⚙️ <strong>Modern Architecture with UIAbility &amp; ArkTS</strong><br> HarmonyOS NEXT apps are fully built on ArkTS and UIAbility, enabling better lifecycle management, dependency injection, and a clearer MVVM structure.</p><p>· 🧠 <strong>Built-in Decorator-Based State System</strong><br> With @State, @Provide, and @Watch, developers can manage local and shared state without relying on third-party libraries.</p><p>· 🔗 <strong>Two-Way Binding and Fine-Grained Reactivity</strong><br> @Link and @Watch make it easy to build complex UI flows with precise state tracking.</p><p>· 🌐 <strong>Designed for Distributed, Cross-Device Experiences</strong><br> HarmonyOS allows seamless interactions across phones, tablets, TVs, and IoT devices — all sharing a unified UI layer and state system.</p><p>✅ <strong>Pros:</strong></p><p>· Fully native performance without bridges</p><p>· Reactive, declarative UI with a clean and structured syntax</p><p>· Advanced integration with HarmonyOS NEXT platform features</p><p>· ArkTS brings type safety, editor support, and developer efficiency</p><p>❌ <strong>Cons:</strong></p><p>· New and evolving ecosystem (limited libraries and community, for now)</p><p>· HarmonyOS-only (doesn’t target Android/iOS)</p><h4>⚙️ Performance &amp; Scalability Insights</h4><p>· <strong>Flutter</strong>: Highly optimized UI rendering with Skia. Scales well with tools like Riverpod and Bloc. Ideal for complex UIs and animations.</p><p>· <strong>Jetpack Compose</strong>: Smart recomposition via Compose compiler. Kotlin coroutines and Flow help manage async state efficiently.</p><p>· <strong>React Native</strong>: Flexible but relies on a JS-to-native bridge, which can slow down performance in state-heavy apps.</p><p>· <strong>SwiftUI</strong>: Native rendering on Apple devices. Reactive updates are efficient, but deep view trees can impact performance.</p><p>· <strong>ArkUI (ArkTS)</strong>: No bridge — <strong>true native</strong>. Built for distributed devices. Fine-grained reactivity (@Watch, @Link) makes it fast and scalable across screens and devices.</p><h4>✅ Quick Recommendations:</h4><p>· Choose <strong>Flutter</strong> if you want wide platform support and strong tooling.</p><p>· Choose <strong>Compose</strong> if you’re targeting Android with modern patterns.</p><p>· Choose <strong>React Native</strong> if you already work with React and need JS flexibility.</p><p>· Choose <strong>SwiftUI</strong> for beautiful, performant iOS/macOS apps.</p><p>· Choose <strong>ArkUI</strong> if you’re building for <strong>HarmonyOS NEXT</strong> and want <strong>native, distributed</strong>, and <strong>future-proof</strong> architecture.</p><h3>Conclusion</h3><p>State management is the backbone of every modern UI framework. Whether you’re building a startup MVP or a large-scale enterprise app, choosing the right state management approach directly impacts your app’s performance, maintainability, and developer experience.</p><p>Each framework — Flutter, Jetpack Compose, React Native, SwiftUI, and ArkUI — offers a unique philosophy for handling state:</p><p>· Some are lightweight and easy to get started with,</p><p>· Others are powerful and scalable for complex apps,</p><p>· And some, like ArkUI, are built from the ground up for <strong>multi-device, distributed systems</strong>.</p><p>Ultimately, there’s no universal “best” — only the <strong>best fit</strong> for your <strong>platform</strong>, <strong>team</strong>, and <strong>goals</strong>. As mobile ecosystems evolve, mastering the core principles of state management across these frameworks will make you a more adaptable and forward-thinking developer.</p><h3>References</h3><p><a href="https://developer.huawei.com/consumer/en/doc/harmonyos-guides-V13/arkts-state-management-overview-V13">Document</a></p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=00174e545e31" width="1" height="1" alt=""><hr><p><a href="https://medium.com/huawei-developers/state-management-showdown-flutter-vs-compose-vs-react-native-vs-swiftui-vs-arkui-in-2025-00174e545e31">State Management Showdown: Flutter vs Compose vs React Native vs SwiftUI vs ArkUI in 2025</a> was originally published in <a href="https://medium.com/huawei-developers">Huawei Developers</a> on Medium, where people are continuing the conversation by highlighting and responding to this story.</p>]]></content:encoded>
        </item>
    </channel>
</rss>