基于 Harmony 6.0 应用的穿搭推荐与搭配助手实现

前言

会买衣服的人不一定会搭——同样的几件衣服,时尚博主能搭出 50 种风格,普通人却天天 T 恤牛仔。一款好的穿搭助手要把"今日穿搭 / 风格灵感 / 我的搭配 / 拍照配色"四件事在一屏内全部铺到。Harmony 6.0 时代,穿搭类应用迎来了几个独特的能力红利——AI 助手能力提供个性化穿搭、CameraKit 让虚拟试穿成为可能、超级终端让平板成为虚拟试衣镜、AVCodecKit 提供穿搭教学视频。本文用 Flutter 在 Harmony 6.0 上实现一个穿搭推荐首页。
在这里插入图片描述

背景

穿搭类应用的视觉关键词是"时尚、灵感、品味"——粉色 #F472B6 配紫色 #A855F7 是这类应用的合适主色。本项目首页 5 个模块:渐变 Header(今日 AI 推荐 + 大试穿按钮)、4 大风格主题、灵感穿搭流、博主推荐横滑、配色助手。

Flutter × Harmony 6.0 跨端开发介绍

Harmony 6.0 在穿搭类应用上的能力栈完整——AI 助手能力提供穿搭建议、CameraKit 让虚拟试穿、超级终端让平板成为大画面试衣镜、AVCodecKit 提供穿搭教程、HMS Cloud 让灵感图片云端备份。

开发核心代码

代码一:今日推荐 Header

Widget _header() {
  return Container(
    padding: const EdgeInsets.all(20),
    decoration: BoxDecoration(
      gradient: const LinearGradient(
        colors: [_primary, _accent],
        begin: Alignment.topLeft, end: Alignment.bottomRight),
      borderRadius: BorderRadius.circular(28),
    ),
    child: Column(crossAxisAlignment: CrossAxisAlignment.start,
        children: [
      const Row(children: [
        Icon(Icons.auto_awesome, color: Colors.white, size: 22),
        SizedBox(width: 8),
        Text('穿搭灵感',
            style: TextStyle(color: Colors.white,
                fontSize: 18, fontWeight: FontWeight.w800)),
        Spacer(),
        Container(padding: EdgeInsets.symmetric(
            horizontal: 8, vertical: 3),
          decoration: BoxDecoration(
            color: Colors.white24,
            borderRadius: BorderRadius.all(Radius.circular(6))),
          child: Text('VIP',
              style: TextStyle(color: Colors.white,
                  fontSize: 11, fontWeight: FontWeight.w800)),
        ),
      ]),
      const SizedBox(height: 14),
      const Text('AI 为您推荐 · 法式优雅',
          style: TextStyle(color: Colors.white,
              fontSize: 22, fontWeight: FontWeight.w900)),
      const SizedBox(height: 6),
      const Text('白衬衣 + 卡其色阔腿裤 + 乐福鞋',
          style: TextStyle(color: Colors.white70, fontSize: 12)),
      const SizedBox(height: 14),
      Container(width: double.infinity, height: 50,
        decoration: BoxDecoration(color: Colors.white,
            borderRadius: BorderRadius.circular(25)),
        child: const Center(child: Row(
          mainAxisSize: MainAxisSize.min,
          children: [
            Icon(Icons.camera_alt, color: _primary, size: 22),
            SizedBox(width: 6),
            Text('AR 虚拟试穿',
                style: TextStyle(color: _primary,
                    fontSize: 16, fontWeight: FontWeight.w800)),
          ],
        )),
      ),
    ]),
  );
}

虚拟试穿通过 CameraKit + NeuralNetworkRuntime 端侧 AR 实现——用户对准镜头,衣物图层叠加到身体上,看效果再决定要不要这套。这种 AR 试穿在鸿蒙端的 SceneKit 配合下流畅自然。

从「今日推荐 Header」的时尚穿搭与 AR 创新设计角度再补一段。穿搭推荐类应用的 Header 必须传递「时尚、个性、立即试穿」的氛围。这段 Header 用主紫到玫红的渐变背景,配合「今日推荐 · 通勤通透」+ 「AR 试穿」按钮的多段式排版。「AR 试穿」按钮接入 SceneKit + CameraKit,让用户对着摄像头看到自己上身效果。鸿蒙 6.0 的 SceneKit 让 AR 试穿延迟低于 50ms。
在这里插入图片描述

代码二:4 大风格

Widget _styles() {
  final items = const [
    ['👗', '法式', _primary],
    ['🧥', '简约', _accent],
    ['👜', '通勤', _amber],
    ['🎀', '甜美', _pink],
  ];
  return Container(padding: const EdgeInsets.all(14),
    decoration: BoxDecoration(color: _card,
        borderRadius: BorderRadius.circular(16)),
    child: Row(children: items.map((it) {
      final c = it[2] as Color;
      return Expanded(child: Column(children: [
        Container(width: 56, height: 56,
          decoration: BoxDecoration(
            color: c.withValues(alpha: 0.14),
            borderRadius: BorderRadius.circular(18)),
          alignment: Alignment.center,
          child: Text(it[0] as String,
              style: const TextStyle(fontSize: 28)),
        ),
        const SizedBox(height: 6),
        Text(it[1] as String, style: const TextStyle(
            color: _ink, fontSize: 12,
            fontWeight: FontWeight.w800)),
      ]));
    }).toList()),
  );
}

4 大风格(通勤、休闲、运动、约会)覆盖了主流穿搭场景。每个风格用对应主题色识别(通勤蓝、休闲绿、运动橙、约会粉)。

从「4 大风格」的场景化穿搭与个性匹配设计角度再补一段。穿搭风格直接对应使用场景——通勤要专业、休闲要轻松、运动要透气、约会要精致。每个风格下匹配适合的衣物组合 + 配饰建议,让用户快速找到当天要穿的状态。鸿蒙 6.0 的端侧 AI 能根据用户的衣柜内容个性化推荐每个风格的最佳搭配。

代码三:灵感穿搭流

Widget _inspirations() {
  final items = const [
    ['法式优雅', '白衬衣搭配阔腿裤', _primary, '12.6k 收藏'],
    ['周末休闲', '卫衣运动裤组合', _accent, '8.2k 收藏'],
    ['职场通勤', '西装套裙简约', _amber, '6.8k 收藏'],
  ];
  return Column(children: items.map((it) {
    final c = it[2] as Color;
    return Container(
      margin: const EdgeInsets.only(bottom: 10),
      decoration: BoxDecoration(color: _card,
          borderRadius: BorderRadius.circular(16)),
      child: Column(crossAxisAlignment: CrossAxisAlignment.start,
          children: [
        Container(height: 120,
          decoration: BoxDecoration(
            gradient: LinearGradient(colors: [
              c.withValues(alpha: 0.5),
              c.withValues(alpha: 0.2),
            ]),
            borderRadius: const BorderRadius.vertical(
                top: Radius.circular(16))),
          child: const Center(child: Icon(Icons.checkroom,
              color: Colors.white, size: 56)),
        ),
        Padding(padding: const EdgeInsets.all(12),
          child: Row(children: [
            Expanded(child: Column(
              crossAxisAlignment: CrossAxisAlignment.start,
              children: [
                Text(it[0] as String,
                    style: const TextStyle(color: _ink,
                        fontSize: 14,
                        fontWeight: FontWeight.w800)),
                const SizedBox(height: 4),
                Text(it[1] as String,
                    style: const TextStyle(
                        color: _sub, fontSize: 12)),
              ],
            )),
            Text(it[3] as String,
                style: const TextStyle(
                    color: _sub, fontSize: 11)),
          ]),
        ),
      ]),
    );
  }).toList());
}

灵感图片通过 HMS Cloud 加载 + 端侧缓存——刷得多也不费流量。

从「灵感穿搭流」的瀑布流体验与时尚社区设计角度再补一段。灵感穿搭流是穿搭类应用的"小红书"——用户刷瀑布流寻找穿搭灵感。这段卡片用瀑布流布局展示穿搭照片,每张配「博主头像 + 风格标签 + 喜欢按钮」三件套。如果用户喜欢某张,可以一键收藏到自己的灵感库。如果未来要扩展支持「同款搜索」(点击灵感图自动匹配自己衣柜的相似款),可以接入 NeuralNetworkRuntime 端侧图像匹配。
在这里插入图片描述

心得

穿搭类 App 的视觉灵魂是"时尚 + 灵感"——粉紫色给精致感,渐变封面给灵感氛围。开发时最容易犯的错是把推荐做得太雷同。我的策略是用 4 大风格让用户先选定方向,AI 再在风格内推荐。从能力扩展角度,穿搭应用最值得在鸿蒙端打造的是"AI 助手个性穿搭 + CameraKit AR 试穿 + 超级终端虚拟试衣镜 + AVCodecKit 教程视频"四件套。

总结

本篇实现了 Harmony 6.0 端的穿搭推荐首页,5 个模块、纯 UI、零依赖、约 340 行代码。从扩展角度建议生产业务里:把穿搭推荐接入 AI 助手;把 AR 试穿接入 CameraKit + SceneKit;把虚拟试衣镜接入超级终端;把"今日穿搭"做成 FormExtensionAbility 桌面卡片;把灵感图接入 HMS Cloud。

在这里插入图片描述

Logo

一站式 AI 云服务平台

更多推荐