shared address book (#7229)

Signed-off-by: 21pages <pages21@163.com>
This commit is contained in:
21pages
2024-03-20 15:05:54 +08:00
committed by GitHub
parent ecb70b43df
commit 41da6d552f
73 changed files with 4714 additions and 866 deletions

View File

@@ -1,5 +1,6 @@
import 'dart:convert';
import 'package:flutter/material.dart';
import 'package:flutter_hbb/common.dart';
import 'package:flutter_hbb/consts.dart';
import 'package:flutter_hbb/models/peer_model.dart';
@@ -188,3 +189,107 @@ class RequestException implements Exception {
return "RequestException, statusCode: $statusCode, error: $cause";
}
}
enum ShareRule {
read(1),
readWrite(2),
fullControl(3);
const ShareRule(this.value);
final int value;
static String desc(int v) {
if (v == ShareRule.read.value) {
return translate('Read-only');
}
if (v == ShareRule.readWrite.value) {
return translate('Read/Write');
}
if (v == ShareRule.fullControl.value) {
return translate('Full Control');
}
return v.toString();
}
static String shortDesc(int v) {
if (v == ShareRule.read.value) {
return 'R';
}
if (v == ShareRule.readWrite.value) {
return 'RW';
}
if (v == ShareRule.fullControl.value) {
return 'F';
}
return v.toString();
}
static ShareRule? fromValue(int v) {
if (v == ShareRule.read.value) {
return ShareRule.read;
}
if (v == ShareRule.readWrite.value) {
return ShareRule.readWrite;
}
if (v == ShareRule.fullControl.value) {
return ShareRule.fullControl;
}
return null;
}
}
enum ShareLevel {
user(1),
group(2),
team(3);
const ShareLevel(this.value);
final int value;
static String teamName = translate('Everyone');
}
class AbProfile {
String guid;
String name;
String owner;
String? note;
int rule;
AbProfile(this.guid, this.name, this.owner, this.note, this.rule);
AbProfile.fromJson(Map<String, dynamic> json)
: guid = json['guid'] ?? '',
name = json['name'] ?? '',
owner = json['owner'] ?? '',
note = json['note'] ?? '',
rule = json['rule'] ?? 0;
}
class AbTag {
String name;
int color;
AbTag(this.name, this.color);
AbTag.fromJson(Map<String, dynamic> json)
: name = json['name'] ?? '',
color = json['color'] ?? '';
}
class AbRulePayload {
String guid;
int level;
String name;
int rule;
String? group;
AbRulePayload(this.guid, this.level, this.name, this.rule, {this.group});
AbRulePayload.fromJson(Map<String, dynamic> json)
: guid = json['guid'] ?? '',
level = json['level'] ?? 0,
name = json['name'] ?? '',
rule = json['rule'] ?? 0,
group = json['group'];
}