import 'package:flutter/material.dart'; import 'package:hive/hive.dart'; // flutter packages pub run build_runner build part 'flisp.g.dart'; @HiveType(typeId: 1) class Flisp extends HiveObject { @HiveField(0) late int id; @HiveField(1) late String content; @HiveField(2) late int tagIndex; @HiveField(3) late String imageUrl; @HiveField(4) late String videoUrl; @HiveField(5) late DateTime createTime; @HiveField(6) late DateTime updateTime; FlispTag get tag => FlispTag.values[tagIndex]; set tag(FlispTag value) => tagIndex = value.index; Flisp({ int? id, required this.content, FlispTag tag = FlispTag.study, required this.imageUrl, required this.videoUrl, DateTime? createTime, DateTime? updateTime, }) { // 简单时间戳ID this.id = id ?? DateTime.now().millisecondsSinceEpoch ~/ 1000; this.content = content; this.tag = tag; this.imageUrl = imageUrl; this.videoUrl = videoUrl; this.createTime = createTime ?? DateTime.now(); this.updateTime = updateTime ?? DateTime.now(); } static Flisp getEmpty() { return Flisp( id: DateTime.now().millisecondsSinceEpoch ~/ 1000, content: '', tag: FlispTag.study, imageUrl: '', videoUrl: '', ); } } enum FlispTag { study('学习', Color(0xFF9C27B0), Icons.school), work('工作', Color(0xFF2196F3), Icons.work), life('生活', Color(0xFF4CAF50), Icons.home); final String label; final Color color; final IconData icon; const FlispTag(this.label, this.color, this.icon); } enum FlispTab { all('全部'), life('生活'), work('工作'), study('学习'); final String label; const FlispTab(this.label); }