欢迎加入开源鸿蒙跨平台社区:
https://openharmonycrossplatform.csdn.net

一、项目概述

运行效果图

image-20260408221300909

image-20260408221306342

image-20260408221311664

image-20260408221317371

image-20260408221321619

1.1 应用简介

真心话银行是一款独特的社交互动应用,将真心话游戏与银行存取概念巧妙结合。用户可以将自己的真心话"存入"银行,当需要回答问题时,可以从银行中"取出"一条真心话来回答。这种机制让真心话游戏变得更加有趣,同时也鼓励用户勇敢表达真实的自己。

应用的核心玩法是:存入真心话时,用户写下自己愿意回答的问题或话题;取出真心话时,系统随机抽取一条,用户必须诚实回答。通过这种存取机制,用户可以提前准备自己愿意分享的内容,避免尴尬,同时也能了解他人的真实想法。

1.2 核心理念

真心话不是负担,而是连接彼此的桥梁。真心话银行的设计理念基于以下原则:

设计原则 理论基础 应用体现
自主选择 自我决定理论 用户自主选择存入的内容
诚实表达 真诚沟通理论 鼓励真实的自我表达
社交连接 社会连接理论 通过真心话增进了解
安全边界 心理边界理论 用户控制分享的边界

1.3 核心功能

真心话银行

核心功能

存入真心话

编写问题

选择分类

设置难度

添加备注

取出真心话

随机抽取

分类筛选

难度筛选

必须回答

回答记录

记录答案

时间戳

情绪标记

历史查看

辅助功能

统计分析

分享功能

提醒功能

数据导出

1.4 真心话分类

应用支持多种真心话类型:

分类 图标 颜色 难度 示例问题
情感 💕 #E91E63 你最难忘的一次心动是什么时候?
梦想 🌟 #FFD700 你最想实现的梦想是什么?
遗憾 😢 #3F51B5 你最后悔的一件事是什么?
秘密 🔐 #9C27B0 你有一个从未告诉任何人的秘密吗?
成长 🌱 #4CAF50 你人生中学到的最重要的一课是什么?
价值观 💭 #2196F3 你最看重朋友身上的什么品质?
回忆 📸 #FF9800 你童年最快乐的记忆是什么?
假设 🤔 #00BCD4 如果可以重来,你会改变什么?

1.5 难度等级系统

等级 图标 描述 示例
简单 轻松愉快的话题 你最喜欢的食物是什么?
普通 ⭐⭐ 需要一些思考 你最欣赏自己哪一点?
困难 ⭐⭐⭐ 涉及内心深处 你最害怕失去什么?
极难 ⭐⭐⭐⭐ 非常私密的话题 你有不想让人知道的一面吗?

1.6 技术栈

技术领域 技术选型 版本要求
开发框架 Flutter >= 3.0.0
编程语言 Dart >= 2.17.0
设计规范 Material Design 3 -
动画控制 AnimationController -
状态管理 setState -
目标平台 鸿蒙OS / Web API 21+

1.7 项目结构

lib/
└── main_truth_bank.dart
    ├── TruthBankApp              # 应用入口
    ├── TruthCategory             # 真心话分类枚举
    ├── DifficultyLevel           # 难度等级枚举
    ├── TruthQuestion             # 真心话问题模型
    ├── AnswerRecord              # 回答记录模型
    ├── TruthBankPage             # 主页面(底部导航)
    ├── _buildBankPage            # 银行主页
    ├── _buildDepositPage         # 存入页面
    └── _buildHistoryPage         # 历史记录页

二、系统架构

2.1 整体架构图

Data Layer

Business Logic Layer

Presentation Layer

主页面
TruthBankPage

银行主页

存入真心话

历史记录

存款统计

取出真心话

快速存入

编写问题

选择分类

设置难度

回答列表

统计图表

真心话管理器

随机抽取器

回答记录器

统计分析器

TruthCategory
分类枚举

DifficultyLevel
难度枚举

TruthQuestion
问题模型

AnswerRecord
记录模型

2.2 类图设计

manages

records

has

has

references

TruthBankApp

+Widget build()

«enumeration»

TruthCategory

+String label

+String icon

+Color color

+int defaultDifficulty

+emotion()

+dream()

+regret()

+secret()

+growth()

+value()

+memory()

+hypothesis()

«enumeration»

DifficultyLevel

+String label

+String icon

+int level

+easy()

+normal()

+hard()

+extreme()

TruthQuestion

+String id

+String content

+TruthCategory category

+DifficultyLevel difficulty

+DateTime createdAt

+bool isAnswered

+String? note

AnswerRecord

+String id

+TruthQuestion question

+String answer

+DateTime answeredAt

+String? mood

+int? honestyScore

TruthBankPage

-int _selectedIndex

-List<TruthQuestion> _questions

-List<AnswerRecord> _answers

+Widget build()

-_depositQuestion()

-_withdrawQuestion()

-_recordAnswer()

2.3 存取流程

回答记录 取出弹窗 存入页面 银行主页 用户 回答记录 取出弹窗 存入页面 银行主页 用户 编写真心话 选择分类和难度 确认存入 更新存款统计 点击取出 随机抽取问题 展示问题 输入回答 保存记录 更新历史

2.4 随机抽取算法

全部

分类筛选

难度筛选

用户点击取出

筛选条件

从所有问题中抽取

从指定分类抽取

从指定难度抽取

随机选择

是否已回答?

允许重复?

返回问题

展示问题


三、核心模块设计

3.1 数据模型设计

3.1.1 真心话分类枚举 (TruthCategory)
enum TruthCategory {
  emotion('情感', '💕', Color(0xFFE91E63), 3),
  dream('梦想', '🌟', Color(0xFFFFD700), 2),
  regret('遗憾', '😢', Color(0xFF3F51B5), 3),
  secret('秘密', '🔐', Color(0xFF9C27B0), 4),
  growth('成长', '🌱', Color(0xFF4CAF50), 2),
  value('价值观', '💭', Color(0xFF2196F3), 1),
  memory('回忆', '📸', Color(0xFFFF9800), 1),
  hypothesis('假设', '🤔', Color(0xFF00BCD4), 1);

  final String label;
  final String icon;
  final Color color;
  final int defaultDifficulty;
}
3.1.2 难度等级枚举 (DifficultyLevel)
enum DifficultyLevel {
  easy('简单', '⭐', 1),
  normal('普通', '⭐⭐', 2),
  hard('困难', '⭐⭐⭐', 3),
  extreme('极难', '⭐⭐⭐⭐', 4);

  final String label;
  final String icon;
  final int level;
}
3.1.3 真心话问题模型 (TruthQuestion)
class TruthQuestion {
  final String id;              // 唯一标识
  final String content;         // 问题内容
  final TruthCategory category; // 分类
  final DifficultyLevel difficulty; // 难度
  final DateTime createdAt;     // 创建时间
  final bool isAnswered;        // 是否已回答
  final String? note;           // 备注
}
3.1.4 回答记录模型 (AnswerRecord)
class AnswerRecord {
  final String id;              // 唯一标识
  final TruthQuestion question; // 问题
  final String answer;          // 回答内容
  final DateTime answeredAt;    // 回答时间
  final String? mood;           // 当时心情
  final int? honestyScore;      // 诚实度自评
}
3.1.5 存款分布
25% 18% 15% 12% 10% 8% 7% 5% 真心话存款分布 情感 梦想 遗憾 秘密 成长 价值观 回忆 假设

3.2 页面结构设计

3.2.1 主页面布局

TruthBankPage

IndexedStack

银行主页

存入页面

历史记录

NavigationBar

银行 Tab

存入 Tab

历史 Tab

3.2.2 银行主页结构

银行主页

存款统计卡片

快速存入入口

取出按钮

最近存入列表

总存款数

已回答数

待回答数

随机抽取

分类筛选

难度筛选

3.2.3 存入页面结构

存入真心话

问题输入框

分类选择

难度选择

备注输入

存入按钮

8种分类

4种难度

3.3 随机抽取算法

TruthQuestion _withdrawQuestion({
  TruthCategory? category,
  DifficultyLevel? difficulty,
  bool includeAnswered = false,
}) {
  var pool = _questions.where((q) {
    if (!includeAnswered && q.isAnswered) return false;
    if (category != null && q.category != category) return false;
    if (difficulty != null && q.difficulty != difficulty) return false;
    return true;
  }).toList();
  
  if (pool.isEmpty) {
    throw Exception('没有符合条件的真心话');
  }
  
  pool.shuffle();
  return pool.first;
}

3.4 统计分析算法

Map<String, dynamic> _calculateStatistics() {
  final total = _questions.length;
  final answered = _questions.where((q) => q.isAnswered).length;
  
  final categoryCount = <TruthCategory, int>{};
  for (final category in TruthCategory.values) {
    categoryCount[category] = _questions
        .where((q) => q.category == category)
        .length;
  }
  
  final difficultyCount = <DifficultyLevel, int>{};
  for (final difficulty in DifficultyLevel.values) {
    difficultyCount[difficulty] = _questions
        .where((q) => q.difficulty == difficulty)
        .length;
  }
  
  return {
    'total': total,
    'answered': answered,
    'pending': total - answered,
    'byCategory': categoryCount,
    'byDifficulty': difficultyCount,
  };
}

四、UI设计规范

4.1 配色方案

应用采用温暖的金色主题,象征真心话的珍贵:

颜色类型 色值 用途
主背景 #0F0F1A 深色背景
卡片背景 #1A1A2E 稍浅深色
主色 #FFD700 金色(银行主题)
情感 #E91E63 粉红色
梦想 #FFD700 金色
遗憾 #3F51B5 靛蓝
秘密 #9C27B0 紫色
成长 #4CAF50 绿色
价值观 #2196F3 蓝色
回忆 #FF9800 橙色
假设 #00BCD4 青色

4.2 字体规范

元素 字号 字重 颜色
页面标题 28px Bold #FFFFFF
存款数字 48px Bold #FFD700
问题内容 18px Medium #FFFFFF
分类标签 12px Medium 分类颜色
回答内容 14px Regular #B0BEC5

4.3 组件规范

4.3.1 银行主页界面
┌─────────────────────────────────────────────────┐
│  真心话银行                                      │
│  存入真心话,取出时必须诚实回答                  │
├─────────────────────────────────────────────────┤
│                                                 │
│  ┌─────────────────────────────────────────┐   │
│  │              💰 存款统计                 │   │
│  │                                         │   │
│  │     总存款: 42条                        │   │
│  │     已回答: 28条                        │   │
│  │     待回答: 14条                        │   │
│  │                                         │   │
│  │  ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━   │   │
│  │                                         │   │
│  │         [🏦 取出真心话]                  │   │
│  └─────────────────────────────────────────┘   │
│                                                 │
│  最近存入                                       │
│  ┌─────────────────────────────────────────┐   │
│  │ 💕 你最难忘的一次心动是什么时候?         │   │
│  │ 困难 · 2小时前                          │   │
│  └─────────────────────────────────────────┘   │
│  ┌─────────────────────────────────────────┐   │
│  │ 🌟 你最想实现的梦想是什么?               │   │
│  │ 普通 · 1天前                            │   │
│  └─────────────────────────────────────────┘   │
│                                                 │
└─────────────────────────────────────────────────┘
4.3.2 存入真心话界面
┌─────────────────────────────────────────────────┐
│  存入真心话                                      │
├─────────────────────────────────────────────────┤
│                                                 │
│  编写你的真心话                                  │
│  ┌─────────────────────────────────────────┐   │
│  │                                         │   │
│  │  输入一个你愿意诚实回答的问题...          │   │
│  │                                         │   │
│  │                                         │   │
│  └─────────────────────────────────────────┘   │
│                                                 │
│  选择分类                                        │
│  [💕 情感] [🌟 梦想] [😢 遗憾] [🔐 秘密]        │
│  [🌱 成长] [💭 价值观] [📸 回忆] [🤔 假设]      │
│                                                 │
│  选择难度                                        │
│  [⭐ 简单] [⭐⭐ 普通] [⭐⭐⭐ 困难] [⭐⭐⭐⭐ 极难] │
│                                                 │
│  添加备注(可选)                                  │
│  ┌─────────────────────────────────────────┐   │
│  │ 为什么想存入这个问题?                    │   │
│  └─────────────────────────────────────────┘   │
│                                                 │
│  ┌─────────────────────────────────────────┐   │
│  │              💰 存入银行                  │   │
│  └─────────────────────────────────────────┘   │
│                                                 │
└─────────────────────────────────────────────────┘
4.3.3 取出真心话界面
┌─────────────────────────────────────────────────┐
│                                                 │
│              🎲 取出真心话                       │
│                                                 │
│  ┌─────────────────────────────────────────┐   │
│  │                                         │   │
│  │  💕 情感 · ⭐⭐⭐ 困难                    │   │
│  │                                         │   │
│  │  你最难忘的一次心动是什么时候?           │   │
│  │                                         │   │
│  │  那个人现在在哪里?你们还有联系吗?        │   │
│  │                                         │   │
│  └─────────────────────────────────────────┘   │
│                                                 │
│  你的回答                                        │
│  ┌─────────────────────────────────────────┐   │
│  │                                         │   │
│  │  诚实回答这个问题...                     │   │
│  │                                         │   │
│  │                                         │   │
│  └─────────────────────────────────────────┘   │
│                                                 │
│  当时心情                                        │
│  [😊 开心] [😢 难过] [🤔 思考] [😌 平静]        │
│                                                 │
│  诚实度自评                                      │
│  ━━━━━━━━━━━●━━━━━━━━━━━━  80%                │
│                                                 │
│  ┌─────────────┐  ┌─────────────┐              │
│  │ 跳过        │  │ 提交回答    │              │
│  └─────────────┘  └─────────────┘              │
│                                                 │
└─────────────────────────────────────────────────┘
4.3.4 历史记录界面
┌─────────────────────────────────────────────────┐
│  回答历史                                        │
├─────────────────────────────────────────────────┤
│                                                 │
│  📊 统计概览                                    │
│  ┌─────────────────────────────────────────┐   │
│  │ 总回答: 28条                            │   │
│  │ 平均诚实度: 85%                         │   │
│  │ 最常回答: 情感类                        │   │
│  └─────────────────────────────────────────┘   │
│                                                 │
│  最近回答                                       │
│  ┌─────────────────────────────────────────┐   │
│  │ 💕 你最难忘的一次心动是什么时候?         │   │
│  │                                         │   │
│  │ 回答: 那是高三的时候,在图书馆...         │   │
│  │                                         │   │
│  │ 😊 开心 · 诚实度: 90%                   │   │
│  │ 2024-01-15                              │   │
│  └─────────────────────────────────────────┘   │
│                                                 │
└─────────────────────────────────────────────────┘

五、核心功能实现

5.1 存入真心话

void _depositQuestion({
  required String content,
  required TruthCategory category,
  required DifficultyLevel difficulty,
  String? note,
}) {
  final question = TruthQuestion(
    id: 'question_${DateTime.now().millisecondsSinceEpoch}',
    content: content,
    category: category,
    difficulty: difficulty,
    createdAt: DateTime.now(),
    isAnswered: false,
    note: note,
  );

  setState(() {
    _questions.insert(0, question);
  });
}

5.2 取出真心话

TruthQuestion _withdrawQuestion({
  TruthCategory? category,
  DifficultyLevel? difficulty,
}) {
  var pool = _questions.where((q) {
    if (q.isAnswered) return false;
    if (category != null && q.category != category) return false;
    if (difficulty != null && q.difficulty != difficulty) return false;
    return true;
  }).toList();

  if (pool.isEmpty) {
    throw Exception('没有待回答的真心话');
  }

  pool.shuffle();
  return pool.first;
}

5.3 记录回答

void _recordAnswer({
  required TruthQuestion question,
  required String answer,
  required String mood,
  required int honestyScore,
}) {
  final record = AnswerRecord(
    id: 'answer_${DateTime.now().millisecondsSinceEpoch}',
    question: question,
    answer: answer,
    answeredAt: DateTime.now(),
    mood: mood,
    honestyScore: honestyScore,
  );

  setState(() {
    _answers.insert(0, record);
    final index = _questions.indexWhere((q) => q.id == question.id);
    if (index != -1) {
      _questions[index] = TruthQuestion(
        id: question.id,
        content: question.content,
        category: question.category,
        difficulty: question.difficulty,
        createdAt: question.createdAt,
        isAnswered: true,
        note: question.note,
      );
    }
  });
}

5.4 统计计算

Map<String, dynamic> _calculateStatistics() {
  final total = _questions.length;
  final answered = _questions.where((q) => q.isAnswered).length;
  
  final avgHonesty = _answers.isEmpty
      ? 0.0
      : _answers.map((a) => a.honestyScore ?? 0).reduce((a, b) => a + b) /
          _answers.length;

  return {
    'total': total,
    'answered': answered,
    'pending': total - answered,
    'avgHonesty': avgHonesty,
  };
}

六、交互设计

6.1 存取流程

历史记录 取出弹窗 银行主页 存入页 用户 历史记录 取出弹窗 银行主页 存入页 用户 编写真心话 选择分类和难度 确认存入 更新存款 点击取出 随机抽取 展示问题 输入回答 保存记录

6.2 回答流程

取出真心话

阅读问题

思考回答

输入答案

选择心情

自评诚实度

确认提交?

保存记录

跳过?

标记跳过

更新统计


七、运行说明

7.1 环境要求

环境 版本要求
Flutter SDK >= 3.0.0
Dart SDK >= 2.17.0
鸿蒙OS API 21+

7.2 运行命令

# 查看可用设备
flutter devices

# 运行到Web服务器
flutter run -d web-server -t lib/main_truth_bank.dart --web-port 8141

# 运行到鸿蒙设备
flutter run -d 127.0.0.1:5555 lib/main_truth_bank.dart

# 运行到Windows
flutter run -d windows -t lib/main_truth_bank.dart

# 代码分析
flutter analyze lib/main_truth_bank.dart

八、总结

真心话银行应用将真心话游戏与银行存取概念巧妙结合,让用户可以提前准备自己愿意分享的内容,同时也能通过随机抽取的方式体验惊喜和挑战。应用支持8种真心话分类,4种难度等级,通过存入、取出、回答、记录等核心功能,帮助用户勇敢表达真实的自己。

核心功能涵盖银行主页、存入真心话、回答记录三大模块。银行主页展示存款统计和快速操作入口;存入页面让用户编写问题并分类;回答记录追踪用户的真心话历程。

应用采用Material Design 3设计规范,以金色为主题色象征真心话的珍贵。通过本应用,希望能够帮助用户在安全的环境中勇敢表达,增进自我认知和人际连接。

**存入真心,取出真诚**

Logo

作为“人工智能6S店”的官方数字引擎,为AI开发者与企业提供一个覆盖软硬件全栈、一站式门户。

更多推荐