47 lines
1.7 KiB
Dart
47 lines
1.7 KiB
Dart
import 'ordered_store.dart';
|
|
import 'text_store.dart';
|
|
|
|
/// 홈 화면의 한 구역.
|
|
class HomeItem {
|
|
const HomeItem({required this.id, required this.title, this.visible = true});
|
|
|
|
final String id; // chats | network | family | discover | cards | company | school | group
|
|
final String title;
|
|
final bool visible;
|
|
|
|
HomeItem copyWith({String? title, bool? visible}) =>
|
|
HomeItem(id: id, title: title ?? this.title, visible: visible ?? this.visible);
|
|
|
|
Map<String, Object?> toJson() => {'id': id, 'title': title, 'visible': visible};
|
|
|
|
factory HomeItem.fromJson(Map<String, Object?> m) => HomeItem(
|
|
id: m['id'] as String,
|
|
title: m['title'] as String,
|
|
visible: (m['visible'] as bool?) ?? true,
|
|
);
|
|
}
|
|
|
|
List<HomeItem> defaultHomeItems() => const [
|
|
HomeItem(id: 'chats', title: '채팅'),
|
|
HomeItem(id: 'network', title: '인맥 관계도'),
|
|
HomeItem(id: 'family', title: '가족'),
|
|
HomeItem(id: 'gathering', title: '가족 모임'),
|
|
HomeItem(id: 'company', title: '회사'),
|
|
HomeItem(id: 'school', title: '학교'),
|
|
HomeItem(id: 'group', title: '그룹·여행'),
|
|
HomeItem(id: 'location', title: '위치'),
|
|
HomeItem(id: 'discover', title: '찾기·추천'),
|
|
HomeItem(id: 'cards', title: '내 명함'),
|
|
];
|
|
|
|
/// 홈 구성 (롱프레스 편집: 숨기기·지우기·순서 바꾸기·이름 바꾸기).
|
|
OrderedStore<HomeItem> homeLayoutStore(TextStore store) => OrderedStore<HomeItem>(
|
|
store: store,
|
|
key: 'layout_home',
|
|
defaults: defaultHomeItems,
|
|
toJson: (i) => i.toJson(),
|
|
fromJson: HomeItem.fromJson,
|
|
idOf: (i) => i.id,
|
|
legacyIds: const ['chats', 'network', 'family', 'company', 'school', 'group', 'location', 'discover', 'cards'],
|
|
);
|