81 lines
2.8 KiB
Dart
81 lines
2.8 KiB
Dart
import 'package:friendly_map/modules/core/core.dart';
|
|
|
|
/// 공개 단계.
|
|
enum VLevel {
|
|
open('공개'),
|
|
partial('일부'),
|
|
hidden('숨김');
|
|
|
|
const VLevel(this.label);
|
|
final String label;
|
|
|
|
/// 공개 → 일부 → 숨김 → 공개 순서로 돌린다 (표의 칸을 누를 때).
|
|
VLevel get next => VLevel.values[(index + 1) % VLevel.values.length];
|
|
|
|
/// 더 많이 보여 주는 쪽.
|
|
static VLevel moreOpen(VLevel a, VLevel b) => a.index <= b.index ? a : b;
|
|
}
|
|
|
|
/// 정보 묶음 (표의 행).
|
|
class VCategory {
|
|
static const school = 'school';
|
|
static const work = 'work';
|
|
static const birthday = 'birthday';
|
|
static const contact = 'contact';
|
|
static const location = 'location';
|
|
static const all = [school, work, birthday, contact, location];
|
|
|
|
static String label(String c) => switch (c) {
|
|
school => '학교',
|
|
work => '회사·직책',
|
|
birthday => '생일',
|
|
contact => '연락처',
|
|
location => '실시간 위치',
|
|
_ => c,
|
|
};
|
|
|
|
/// 명함 항목 이름 → 정보 묶음. 이름·가족 관계처럼 어느 묶음에도 없으면 null (항상 보인다).
|
|
static String? ofKey(String key) => switch (key) {
|
|
CardKeys.school || CardKeys.level || CardKeys.year || CardKeys.major => school,
|
|
CardKeys.company || CardKeys.position || CardKeys.former => work,
|
|
CardKeys.birthday => birthday,
|
|
CardKeys.phone || CardKeys.email => contact,
|
|
_ => null,
|
|
};
|
|
}
|
|
|
|
/// 받는 사람의 관계 묶음 (표의 열).
|
|
class VAudience {
|
|
static const family = 'family';
|
|
static const company = 'company';
|
|
static const school = 'school';
|
|
static const group = 'group';
|
|
static const all = [family, company, school, group];
|
|
|
|
static String label(String a) => switch (a) {
|
|
family => '가족',
|
|
company => '회사',
|
|
school => '동문',
|
|
group => '그룹',
|
|
_ => a,
|
|
};
|
|
|
|
/// 연결 관계 글자(예: "가족:어머니", "동창", "전 직장 동료", "같은 모임")에서 관계 묶음을 찾는다.
|
|
static String? ofRelation(String relation) {
|
|
if (relation.startsWith('가족')) return family;
|
|
if (relation.contains('직장') || relation.contains('회사') || relation.contains('동료')) return company;
|
|
if (relation.contains('동창') || relation.contains('동문')) return school;
|
|
if (relation.contains('모임') || relation.contains('여행') || relation.contains('그룹')) return group;
|
|
return null;
|
|
}
|
|
|
|
/// 명함 종류 → 관계 묶음. 개인 명함은 특정 관계를 뜻하지 않아 null.
|
|
static String? ofCardKind(String kind) => switch (kind) {
|
|
CardKinds.family => family,
|
|
CardKinds.company => company,
|
|
CardKinds.school => school,
|
|
CardKinds.group => group,
|
|
_ => null,
|
|
};
|
|
}
|