Show an indicator of the collection owner's email on the shared collection icon
This commit is contained in:
parent
94366a2aea
commit
405578b086
5 changed files with 33 additions and 27 deletions
|
@ -13,6 +13,7 @@ class CollectionsDB {
|
|||
|
||||
static final columnID = 'collection_id';
|
||||
static final columnOwnerID = 'owner_id';
|
||||
static final columnOwnerEmail = 'owner_email';
|
||||
static final columnEncryptedKey = 'encrypted_key';
|
||||
static final columnKeyDecryptionNonce = 'key_decryption_nonce';
|
||||
static final columnName = 'name';
|
||||
|
@ -46,6 +47,7 @@ class CollectionsDB {
|
|||
CREATE TABLE $collectionsTable (
|
||||
$columnID INTEGER PRIMARY KEY NOT NULL,
|
||||
$columnOwnerID INTEGER NOT NULL,
|
||||
$columnOwnerEmail TEXT,
|
||||
$columnEncryptedKey TEXT NOT NULL,
|
||||
$columnKeyDecryptionNonce TEXT,
|
||||
$columnName TEXT NOT NULL,
|
||||
|
@ -95,6 +97,7 @@ class CollectionsDB {
|
|||
var row = new Map<String, dynamic>();
|
||||
row[columnID] = collection.id;
|
||||
row[columnOwnerID] = collection.ownerID;
|
||||
row[columnOwnerEmail] = collection.ownerEmail;
|
||||
row[columnEncryptedKey] = collection.encryptedKey;
|
||||
row[columnKeyDecryptionNonce] = collection.keyDecryptionNonce;
|
||||
row[columnName] = collection.name;
|
||||
|
@ -109,6 +112,7 @@ class CollectionsDB {
|
|||
return Collection(
|
||||
row[columnID],
|
||||
row[columnOwnerID],
|
||||
row[columnOwnerEmail],
|
||||
row[columnEncryptedKey],
|
||||
row[columnKeyDecryptionNonce],
|
||||
row[columnName],
|
||||
|
|
|
@ -3,6 +3,7 @@ import 'dart:convert';
|
|||
class Collection {
|
||||
final int id;
|
||||
final int ownerID;
|
||||
final String ownerEmail;
|
||||
final String encryptedKey;
|
||||
final String keyDecryptionNonce;
|
||||
final String name;
|
||||
|
@ -13,6 +14,7 @@ class Collection {
|
|||
Collection(
|
||||
this.id,
|
||||
this.ownerID,
|
||||
this.ownerEmail,
|
||||
this.encryptedKey,
|
||||
this.keyDecryptionNonce,
|
||||
this.name,
|
||||
|
@ -42,28 +44,6 @@ class Collection {
|
|||
}
|
||||
}
|
||||
|
||||
Collection copyWith({
|
||||
int id,
|
||||
int ownerID,
|
||||
String encryptedKey,
|
||||
String keyDecryptionNonce,
|
||||
String name,
|
||||
CollectionType type,
|
||||
CollectionAttributes attributes,
|
||||
int creationTime,
|
||||
}) {
|
||||
return Collection(
|
||||
id ?? this.id,
|
||||
ownerID ?? this.ownerID,
|
||||
encryptedKey ?? this.encryptedKey,
|
||||
keyDecryptionNonce ?? this.keyDecryptionNonce,
|
||||
name ?? this.name,
|
||||
type ?? this.type,
|
||||
attributes ?? this.attributes,
|
||||
creationTime ?? this.creationTime,
|
||||
);
|
||||
}
|
||||
|
||||
Map<String, dynamic> toMap() {
|
||||
return {
|
||||
'id': id,
|
||||
|
@ -83,6 +63,7 @@ class Collection {
|
|||
return Collection(
|
||||
map['id'],
|
||||
map['ownerID'],
|
||||
map['ownerEmail'],
|
||||
map['encryptedKey'],
|
||||
map['keyDecryptionNonce'],
|
||||
map['name'],
|
||||
|
@ -99,7 +80,7 @@ class Collection {
|
|||
|
||||
@override
|
||||
String toString() {
|
||||
return 'Collection(id: $id, ownerID: $ownerID, encryptedKey: $encryptedKey, keyDecryptionNonce: $keyDecryptionNonce, name: $name, type: $type, attributes: $attributes, creationTime: $creationTime)';
|
||||
return 'Collection(id: $id, ownerID: $ownerID, ownerEmail: $ownerEmail, encryptedKey: $encryptedKey, keyDecryptionNonce: $keyDecryptionNonce, name: $name, type: $type, attributes: $attributes, creationTime: $creationTime)';
|
||||
}
|
||||
|
||||
@override
|
||||
|
@ -109,6 +90,7 @@ class Collection {
|
|||
return o is Collection &&
|
||||
o.id == id &&
|
||||
o.ownerID == ownerID &&
|
||||
o.ownerEmail == ownerEmail &&
|
||||
o.encryptedKey == encryptedKey &&
|
||||
o.keyDecryptionNonce == keyDecryptionNonce &&
|
||||
o.name == name &&
|
||||
|
@ -121,6 +103,7 @@ class Collection {
|
|||
int get hashCode {
|
||||
return id.hashCode ^
|
||||
ownerID.hashCode ^
|
||||
ownerEmail.hashCode ^
|
||||
encryptedKey.hashCode ^
|
||||
keyDecryptionNonce.hashCode ^
|
||||
name.hashCode ^
|
||||
|
|
|
@ -145,6 +145,7 @@ class CollectionsService {
|
|||
final key = CryptoUtil.generateKey();
|
||||
final encryptedKeyData = CryptoUtil.encryptSync(key, _config.getKey());
|
||||
final collection = await createAndCacheCollection(Collection(
|
||||
null,
|
||||
null,
|
||||
null,
|
||||
Sodium.bin2base64(encryptedKeyData.encryptedData),
|
||||
|
@ -166,6 +167,7 @@ class CollectionsService {
|
|||
final encryptedPath =
|
||||
CryptoUtil.encryptSync(utf8.encode(path), _config.getKey());
|
||||
final collection = await createAndCacheCollection(Collection(
|
||||
null,
|
||||
null,
|
||||
null,
|
||||
Sodium.bin2base64(encryptedKeyData.encryptedData),
|
||||
|
|
|
@ -92,6 +92,7 @@ class FavoritesService {
|
|||
await _collectionsService.createAndCacheCollection(Collection(
|
||||
null,
|
||||
null,
|
||||
null,
|
||||
Sodium.bin2base64(encryptedKeyData.encryptedData),
|
||||
Sodium.bin2base64(encryptedKeyData.nonce),
|
||||
"Favorites",
|
||||
|
|
|
@ -108,12 +108,28 @@ class _SharedCollectionGalleryState extends State<SharedCollectionGallery> {
|
|||
ClipRRect(
|
||||
borderRadius: BorderRadius.circular(4.0),
|
||||
child: Container(
|
||||
child: c.thumbnail ==
|
||||
null // When the user has shared a folder without photos
|
||||
? Icon(Icons.error)
|
||||
: Hero(
|
||||
child: Stack(
|
||||
children: [
|
||||
Hero(
|
||||
tag: "shared_collection" + c.thumbnail.tag(),
|
||||
child: ThumbnailWidget(c.thumbnail)),
|
||||
Align(
|
||||
alignment: Alignment.bottomRight,
|
||||
child: Container(
|
||||
child: Text(
|
||||
c.collection.ownerEmail.substring(0, 1),
|
||||
textAlign: TextAlign.center,
|
||||
),
|
||||
padding: EdgeInsets.all(8),
|
||||
margin: EdgeInsets.fromLTRB(0, 0, 4, 0),
|
||||
decoration: BoxDecoration(
|
||||
shape: BoxShape.circle,
|
||||
color: Theme.of(context).accentColor,
|
||||
),
|
||||
),
|
||||
),
|
||||
],
|
||||
),
|
||||
height: 150,
|
||||
width: 150,
|
||||
),
|
||||
|
|
Loading…
Add table
Reference in a new issue