♻️ Use sqlite to replace hive #5
| @@ -221,6 +221,25 @@ PODS: | ||||
|   - sqflite_darwin (0.0.4): | ||||
|     - Flutter | ||||
|     - FlutterMacOS | ||||
|   - sqlite3 (3.49.0): | ||||
|     - sqlite3/common (= 3.49.0) | ||||
|   - sqlite3/common (3.49.0) | ||||
|   - sqlite3/dbstatvtab (3.49.0): | ||||
|     - sqlite3/common | ||||
|   - sqlite3/fts5 (3.49.0): | ||||
|     - sqlite3/common | ||||
|   - sqlite3/perf-threadsafe (3.49.0): | ||||
|     - sqlite3/common | ||||
|   - sqlite3/rtree (3.49.0): | ||||
|     - sqlite3/common | ||||
|   - sqlite3_flutter_libs (0.0.1): | ||||
|     - Flutter | ||||
|     - FlutterMacOS | ||||
|     - sqlite3 (~> 3.49.0) | ||||
|     - sqlite3/dbstatvtab | ||||
|     - sqlite3/fts5 | ||||
|     - sqlite3/perf-threadsafe | ||||
|     - sqlite3/rtree | ||||
|   - SwiftyGif (5.4.5) | ||||
|   - url_launcher_ios (0.0.1): | ||||
|     - Flutter | ||||
| @@ -268,6 +287,7 @@ DEPENDENCIES: | ||||
|   - share_plus (from `.symlinks/plugins/share_plus/ios`) | ||||
|   - shared_preferences_foundation (from `.symlinks/plugins/shared_preferences_foundation/darwin`) | ||||
|   - sqflite_darwin (from `.symlinks/plugins/sqflite_darwin/darwin`) | ||||
|   - sqlite3_flutter_libs (from `.symlinks/plugins/sqlite3_flutter_libs/darwin`) | ||||
|   - url_launcher_ios (from `.symlinks/plugins/url_launcher_ios/ios`) | ||||
|   - video_compress (from `.symlinks/plugins/video_compress/ios`) | ||||
|   - volume_controller (from `.symlinks/plugins/volume_controller/ios`) | ||||
| @@ -294,6 +314,7 @@ SPEC REPOS: | ||||
|     - PromisesObjC | ||||
|     - SAMKeychain | ||||
|     - SDWebImage | ||||
|     - sqlite3 | ||||
|     - SwiftyGif | ||||
|     - WebRTC-SDK | ||||
|  | ||||
| @@ -360,6 +381,8 @@ EXTERNAL SOURCES: | ||||
|     :path: ".symlinks/plugins/shared_preferences_foundation/darwin" | ||||
|   sqflite_darwin: | ||||
|     :path: ".symlinks/plugins/sqflite_darwin/darwin" | ||||
|   sqlite3_flutter_libs: | ||||
|     :path: ".symlinks/plugins/sqlite3_flutter_libs/darwin" | ||||
|   url_launcher_ios: | ||||
|     :path: ".symlinks/plugins/url_launcher_ios/ios" | ||||
|   video_compress: | ||||
| @@ -421,6 +444,8 @@ SPEC CHECKSUMS: | ||||
|   share_plus: 8b6f8b3447e494cca5317c8c3073de39b3600d1f | ||||
|   shared_preferences_foundation: fcdcbc04712aee1108ac7fda236f363274528f78 | ||||
|   sqflite_darwin: 5a7236e3b501866c1c9befc6771dfd73ffb8702d | ||||
|   sqlite3: 4922312598b67e1825c6a6c821296dcbf6783046 | ||||
|   sqlite3_flutter_libs: 069c435986dd4b63461aecd68f4b30be4a9e9daa | ||||
|   SwiftyGif: 706c60cf65fa2bc5ee0313beece843c8eb8194d4 | ||||
|   url_launcher_ios: 5334b05cef931de560670eeae103fd3e431ac3fe | ||||
|   video_compress: fce97e4fb1dfd88175aa07d2ffc8a2f297f87fbe | ||||
|   | ||||
							
								
								
									
										26
									
								
								lib/database/chat.dart
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										26
									
								
								lib/database/chat.dart
									
									
									
									
									
										Normal file
									
								
							| @@ -0,0 +1,26 @@ | ||||
| import 'package:drift/drift.dart'; | ||||
| import 'package:surface/types/chat.dart'; | ||||
|  | ||||
| class SnLocalChatChannel extends Table { | ||||
|   IntColumn get id => integer().autoIncrement()(); | ||||
|  | ||||
|   BlobColumn get content => blob().map(TypeConverter.jsonb( | ||||
|     fromJson: (json) => SnChannel.fromJson(json as Map<String, Object?>), | ||||
|     toJson: (pref) => pref.toJson(), | ||||
|   ))(); | ||||
|  | ||||
|   DateTimeColumn get createdAt => dateTime().withDefault(currentDateAndTime)(); | ||||
| } | ||||
|  | ||||
| class SnLocalChatMessage extends Table { | ||||
|   IntColumn get id => integer().autoIncrement()(); | ||||
|  | ||||
|   IntColumn get channelId => integer()(); | ||||
|  | ||||
|   BlobColumn get content => blob().map( TypeConverter.jsonb( | ||||
|     fromJson: (json) => SnChatMessage.fromJson(json as Map<String, Object?>), | ||||
|     toJson: (pref) => pref.toJson(), | ||||
|   ))(); | ||||
|  | ||||
|   DateTimeColumn get createdAt => dateTime().withDefault(currentDateAndTime)(); | ||||
| } | ||||
							
								
								
									
										28
									
								
								lib/database/database.dart
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										28
									
								
								lib/database/database.dart
									
									
									
									
									
										Normal file
									
								
							| @@ -0,0 +1,28 @@ | ||||
| import 'package:drift/drift.dart'; | ||||
| import 'package:drift_flutter/drift_flutter.dart'; | ||||
| import 'package:path_provider/path_provider.dart'; | ||||
| import 'package:surface/database/chat.dart'; | ||||
| import 'package:surface/types/chat.dart'; | ||||
|  | ||||
| part 'database.g.dart'; | ||||
|  | ||||
| @DriftDatabase(tables: [SnLocalChatChannel, SnLocalChatMessage]) | ||||
| class AppDatabase extends _$AppDatabase { | ||||
|   AppDatabase() : super(_openConnection()); | ||||
|  | ||||
|   @override | ||||
|   int get schemaVersion => 1; | ||||
|  | ||||
|   static QueryExecutor _openConnection() { | ||||
|     return driftDatabase( | ||||
|       name: 'solar_network_data', | ||||
|       native: const DriftNativeOptions( | ||||
|         databaseDirectory: getApplicationSupportDirectory, | ||||
|       ), | ||||
|       web: DriftWebOptions( | ||||
|         sqlite3Wasm: Uri.parse('sqlite3.wasm'), | ||||
|         driftWorker: Uri.parse('drift_worker.dart.js'), | ||||
|       ), | ||||
|     ); | ||||
|   } | ||||
| } | ||||
							
								
								
									
										831
									
								
								lib/database/database.g.dart
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										831
									
								
								lib/database/database.g.dart
									
									
									
									
									
										Normal file
									
								
							| @@ -0,0 +1,831 @@ | ||||
| // GENERATED CODE - DO NOT MODIFY BY HAND | ||||
|  | ||||
| part of 'database.dart'; | ||||
|  | ||||
| // ignore_for_file: type=lint | ||||
| class $SnLocalChatChannelTable extends SnLocalChatChannel | ||||
|     with TableInfo<$SnLocalChatChannelTable, SnLocalChatChannelData> { | ||||
|   @override | ||||
|   final GeneratedDatabase attachedDatabase; | ||||
|   final String? _alias; | ||||
|   $SnLocalChatChannelTable(this.attachedDatabase, [this._alias]); | ||||
|   static const VerificationMeta _idMeta = const VerificationMeta('id'); | ||||
|   @override | ||||
|   late final GeneratedColumn<int> id = GeneratedColumn<int>( | ||||
|       'id', aliasedName, false, | ||||
|       hasAutoIncrement: true, | ||||
|       type: DriftSqlType.int, | ||||
|       requiredDuringInsert: false, | ||||
|       defaultConstraints: | ||||
|           GeneratedColumn.constraintIsAlways('PRIMARY KEY AUTOINCREMENT')); | ||||
|   static const VerificationMeta _contentMeta = | ||||
|       const VerificationMeta('content'); | ||||
|   @override | ||||
|   late final GeneratedColumnWithTypeConverter<SnChannel, Uint8List> content = | ||||
|       GeneratedColumn<Uint8List>('content', aliasedName, false, | ||||
|               type: DriftSqlType.blob, requiredDuringInsert: true) | ||||
|           .withConverter<SnChannel>($SnLocalChatChannelTable.$convertercontent); | ||||
|   static const VerificationMeta _createdAtMeta = | ||||
|       const VerificationMeta('createdAt'); | ||||
|   @override | ||||
|   late final GeneratedColumn<DateTime> createdAt = GeneratedColumn<DateTime>( | ||||
|       'created_at', aliasedName, false, | ||||
|       type: DriftSqlType.dateTime, | ||||
|       requiredDuringInsert: false, | ||||
|       defaultValue: currentDateAndTime); | ||||
|   @override | ||||
|   List<GeneratedColumn> get $columns => [id, content, createdAt]; | ||||
|   @override | ||||
|   String get aliasedName => _alias ?? actualTableName; | ||||
|   @override | ||||
|   String get actualTableName => $name; | ||||
|   static const String $name = 'sn_local_chat_channel'; | ||||
|   @override | ||||
|   VerificationContext validateIntegrity( | ||||
|       Insertable<SnLocalChatChannelData> instance, | ||||
|       {bool isInserting = false}) { | ||||
|     final context = VerificationContext(); | ||||
|     final data = instance.toColumns(true); | ||||
|     if (data.containsKey('id')) { | ||||
|       context.handle(_idMeta, id.isAcceptableOrUnknown(data['id']!, _idMeta)); | ||||
|     } | ||||
|     context.handle(_contentMeta, const VerificationResult.success()); | ||||
|     if (data.containsKey('created_at')) { | ||||
|       context.handle(_createdAtMeta, | ||||
|           createdAt.isAcceptableOrUnknown(data['created_at']!, _createdAtMeta)); | ||||
|     } | ||||
|     return context; | ||||
|   } | ||||
|  | ||||
|   @override | ||||
|   Set<GeneratedColumn> get $primaryKey => {id}; | ||||
|   @override | ||||
|   SnLocalChatChannelData map(Map<String, dynamic> data, {String? tablePrefix}) { | ||||
|     final effectivePrefix = tablePrefix != null ? '$tablePrefix.' : ''; | ||||
|     return SnLocalChatChannelData( | ||||
|       id: attachedDatabase.typeMapping | ||||
|           .read(DriftSqlType.int, data['${effectivePrefix}id'])!, | ||||
|       content: $SnLocalChatChannelTable.$convertercontent.fromSql( | ||||
|           attachedDatabase.typeMapping | ||||
|               .read(DriftSqlType.blob, data['${effectivePrefix}content'])!), | ||||
|       createdAt: attachedDatabase.typeMapping | ||||
|           .read(DriftSqlType.dateTime, data['${effectivePrefix}created_at'])!, | ||||
|     ); | ||||
|   } | ||||
|  | ||||
|   @override | ||||
|   $SnLocalChatChannelTable createAlias(String alias) { | ||||
|     return $SnLocalChatChannelTable(attachedDatabase, alias); | ||||
|   } | ||||
|  | ||||
|   static JsonTypeConverter2<SnChannel, Uint8List, Object?> $convertercontent = | ||||
|       TypeConverter.jsonb( | ||||
|           fromJson: (json) => SnChannel.fromJson(json as Map<String, Object?>), | ||||
|           toJson: (pref) => pref.toJson()); | ||||
| } | ||||
|  | ||||
| class SnLocalChatChannelData extends DataClass | ||||
|     implements Insertable<SnLocalChatChannelData> { | ||||
|   final int id; | ||||
|   final SnChannel content; | ||||
|   final DateTime createdAt; | ||||
|   const SnLocalChatChannelData( | ||||
|       {required this.id, required this.content, required this.createdAt}); | ||||
|   @override | ||||
|   Map<String, Expression> toColumns(bool nullToAbsent) { | ||||
|     final map = <String, Expression>{}; | ||||
|     map['id'] = Variable<int>(id); | ||||
|     { | ||||
|       map['content'] = Variable<Uint8List>( | ||||
|           $SnLocalChatChannelTable.$convertercontent.toSql(content)); | ||||
|     } | ||||
|     map['created_at'] = Variable<DateTime>(createdAt); | ||||
|     return map; | ||||
|   } | ||||
|  | ||||
|   SnLocalChatChannelCompanion toCompanion(bool nullToAbsent) { | ||||
|     return SnLocalChatChannelCompanion( | ||||
|       id: Value(id), | ||||
|       content: Value(content), | ||||
|       createdAt: Value(createdAt), | ||||
|     ); | ||||
|   } | ||||
|  | ||||
|   factory SnLocalChatChannelData.fromJson(Map<String, dynamic> json, | ||||
|       {ValueSerializer? serializer}) { | ||||
|     serializer ??= driftRuntimeOptions.defaultSerializer; | ||||
|     return SnLocalChatChannelData( | ||||
|       id: serializer.fromJson<int>(json['id']), | ||||
|       content: $SnLocalChatChannelTable.$convertercontent | ||||
|           .fromJson(serializer.fromJson<Object?>(json['content'])), | ||||
|       createdAt: serializer.fromJson<DateTime>(json['createdAt']), | ||||
|     ); | ||||
|   } | ||||
|   @override | ||||
|   Map<String, dynamic> toJson({ValueSerializer? serializer}) { | ||||
|     serializer ??= driftRuntimeOptions.defaultSerializer; | ||||
|     return <String, dynamic>{ | ||||
|       'id': serializer.toJson<int>(id), | ||||
|       'content': serializer.toJson<Object?>( | ||||
|           $SnLocalChatChannelTable.$convertercontent.toJson(content)), | ||||
|       'createdAt': serializer.toJson<DateTime>(createdAt), | ||||
|     }; | ||||
|   } | ||||
|  | ||||
|   SnLocalChatChannelData copyWith( | ||||
|           {int? id, SnChannel? content, DateTime? createdAt}) => | ||||
|       SnLocalChatChannelData( | ||||
|         id: id ?? this.id, | ||||
|         content: content ?? this.content, | ||||
|         createdAt: createdAt ?? this.createdAt, | ||||
|       ); | ||||
|   SnLocalChatChannelData copyWithCompanion(SnLocalChatChannelCompanion data) { | ||||
|     return SnLocalChatChannelData( | ||||
|       id: data.id.present ? data.id.value : this.id, | ||||
|       content: data.content.present ? data.content.value : this.content, | ||||
|       createdAt: data.createdAt.present ? data.createdAt.value : this.createdAt, | ||||
|     ); | ||||
|   } | ||||
|  | ||||
|   @override | ||||
|   String toString() { | ||||
|     return (StringBuffer('SnLocalChatChannelData(') | ||||
|           ..write('id: $id, ') | ||||
|           ..write('content: $content, ') | ||||
|           ..write('createdAt: $createdAt') | ||||
|           ..write(')')) | ||||
|         .toString(); | ||||
|   } | ||||
|  | ||||
|   @override | ||||
|   int get hashCode => Object.hash(id, content, createdAt); | ||||
|   @override | ||||
|   bool operator ==(Object other) => | ||||
|       identical(this, other) || | ||||
|       (other is SnLocalChatChannelData && | ||||
|           other.id == this.id && | ||||
|           other.content == this.content && | ||||
|           other.createdAt == this.createdAt); | ||||
| } | ||||
|  | ||||
| class SnLocalChatChannelCompanion | ||||
|     extends UpdateCompanion<SnLocalChatChannelData> { | ||||
|   final Value<int> id; | ||||
|   final Value<SnChannel> content; | ||||
|   final Value<DateTime> createdAt; | ||||
|   const SnLocalChatChannelCompanion({ | ||||
|     this.id = const Value.absent(), | ||||
|     this.content = const Value.absent(), | ||||
|     this.createdAt = const Value.absent(), | ||||
|   }); | ||||
|   SnLocalChatChannelCompanion.insert({ | ||||
|     this.id = const Value.absent(), | ||||
|     required SnChannel content, | ||||
|     this.createdAt = const Value.absent(), | ||||
|   }) : content = Value(content); | ||||
|   static Insertable<SnLocalChatChannelData> custom({ | ||||
|     Expression<int>? id, | ||||
|     Expression<Uint8List>? content, | ||||
|     Expression<DateTime>? createdAt, | ||||
|   }) { | ||||
|     return RawValuesInsertable({ | ||||
|       if (id != null) 'id': id, | ||||
|       if (content != null) 'content': content, | ||||
|       if (createdAt != null) 'created_at': createdAt, | ||||
|     }); | ||||
|   } | ||||
|  | ||||
|   SnLocalChatChannelCompanion copyWith( | ||||
|       {Value<int>? id, Value<SnChannel>? content, Value<DateTime>? createdAt}) { | ||||
|     return SnLocalChatChannelCompanion( | ||||
|       id: id ?? this.id, | ||||
|       content: content ?? this.content, | ||||
|       createdAt: createdAt ?? this.createdAt, | ||||
|     ); | ||||
|   } | ||||
|  | ||||
|   @override | ||||
|   Map<String, Expression> toColumns(bool nullToAbsent) { | ||||
|     final map = <String, Expression>{}; | ||||
|     if (id.present) { | ||||
|       map['id'] = Variable<int>(id.value); | ||||
|     } | ||||
|     if (content.present) { | ||||
|       map['content'] = Variable<Uint8List>( | ||||
|           $SnLocalChatChannelTable.$convertercontent.toSql(content.value)); | ||||
|     } | ||||
|     if (createdAt.present) { | ||||
|       map['created_at'] = Variable<DateTime>(createdAt.value); | ||||
|     } | ||||
|     return map; | ||||
|   } | ||||
|  | ||||
|   @override | ||||
|   String toString() { | ||||
|     return (StringBuffer('SnLocalChatChannelCompanion(') | ||||
|           ..write('id: $id, ') | ||||
|           ..write('content: $content, ') | ||||
|           ..write('createdAt: $createdAt') | ||||
|           ..write(')')) | ||||
|         .toString(); | ||||
|   } | ||||
| } | ||||
|  | ||||
| class $SnLocalChatMessageTable extends SnLocalChatMessage | ||||
|     with TableInfo<$SnLocalChatMessageTable, SnLocalChatMessageData> { | ||||
|   @override | ||||
|   final GeneratedDatabase attachedDatabase; | ||||
|   final String? _alias; | ||||
|   $SnLocalChatMessageTable(this.attachedDatabase, [this._alias]); | ||||
|   static const VerificationMeta _idMeta = const VerificationMeta('id'); | ||||
|   @override | ||||
|   late final GeneratedColumn<int> id = GeneratedColumn<int>( | ||||
|       'id', aliasedName, false, | ||||
|       hasAutoIncrement: true, | ||||
|       type: DriftSqlType.int, | ||||
|       requiredDuringInsert: false, | ||||
|       defaultConstraints: | ||||
|           GeneratedColumn.constraintIsAlways('PRIMARY KEY AUTOINCREMENT')); | ||||
|   static const VerificationMeta _channelIdMeta = | ||||
|       const VerificationMeta('channelId'); | ||||
|   @override | ||||
|   late final GeneratedColumn<int> channelId = GeneratedColumn<int>( | ||||
|       'channel_id', aliasedName, false, | ||||
|       type: DriftSqlType.int, requiredDuringInsert: true); | ||||
|   static const VerificationMeta _contentMeta = | ||||
|       const VerificationMeta('content'); | ||||
|   @override | ||||
|   late final GeneratedColumnWithTypeConverter<SnChatMessage, Uint8List> | ||||
|       content = GeneratedColumn<Uint8List>('content', aliasedName, false, | ||||
|               type: DriftSqlType.blob, requiredDuringInsert: true) | ||||
|           .withConverter<SnChatMessage>( | ||||
|               $SnLocalChatMessageTable.$convertercontent); | ||||
|   static const VerificationMeta _createdAtMeta = | ||||
|       const VerificationMeta('createdAt'); | ||||
|   @override | ||||
|   late final GeneratedColumn<DateTime> createdAt = GeneratedColumn<DateTime>( | ||||
|       'created_at', aliasedName, false, | ||||
|       type: DriftSqlType.dateTime, | ||||
|       requiredDuringInsert: false, | ||||
|       defaultValue: currentDateAndTime); | ||||
|   @override | ||||
|   List<GeneratedColumn> get $columns => [id, channelId, content, createdAt]; | ||||
|   @override | ||||
|   String get aliasedName => _alias ?? actualTableName; | ||||
|   @override | ||||
|   String get actualTableName => $name; | ||||
|   static const String $name = 'sn_local_chat_message'; | ||||
|   @override | ||||
|   VerificationContext validateIntegrity( | ||||
|       Insertable<SnLocalChatMessageData> instance, | ||||
|       {bool isInserting = false}) { | ||||
|     final context = VerificationContext(); | ||||
|     final data = instance.toColumns(true); | ||||
|     if (data.containsKey('id')) { | ||||
|       context.handle(_idMeta, id.isAcceptableOrUnknown(data['id']!, _idMeta)); | ||||
|     } | ||||
|     if (data.containsKey('channel_id')) { | ||||
|       context.handle(_channelIdMeta, | ||||
|           channelId.isAcceptableOrUnknown(data['channel_id']!, _channelIdMeta)); | ||||
|     } else if (isInserting) { | ||||
|       context.missing(_channelIdMeta); | ||||
|     } | ||||
|     context.handle(_contentMeta, const VerificationResult.success()); | ||||
|     if (data.containsKey('created_at')) { | ||||
|       context.handle(_createdAtMeta, | ||||
|           createdAt.isAcceptableOrUnknown(data['created_at']!, _createdAtMeta)); | ||||
|     } | ||||
|     return context; | ||||
|   } | ||||
|  | ||||
|   @override | ||||
|   Set<GeneratedColumn> get $primaryKey => {id}; | ||||
|   @override | ||||
|   SnLocalChatMessageData map(Map<String, dynamic> data, {String? tablePrefix}) { | ||||
|     final effectivePrefix = tablePrefix != null ? '$tablePrefix.' : ''; | ||||
|     return SnLocalChatMessageData( | ||||
|       id: attachedDatabase.typeMapping | ||||
|           .read(DriftSqlType.int, data['${effectivePrefix}id'])!, | ||||
|       channelId: attachedDatabase.typeMapping | ||||
|           .read(DriftSqlType.int, data['${effectivePrefix}channel_id'])!, | ||||
|       content: $SnLocalChatMessageTable.$convertercontent.fromSql( | ||||
|           attachedDatabase.typeMapping | ||||
|               .read(DriftSqlType.blob, data['${effectivePrefix}content'])!), | ||||
|       createdAt: attachedDatabase.typeMapping | ||||
|           .read(DriftSqlType.dateTime, data['${effectivePrefix}created_at'])!, | ||||
|     ); | ||||
|   } | ||||
|  | ||||
|   @override | ||||
|   $SnLocalChatMessageTable createAlias(String alias) { | ||||
|     return $SnLocalChatMessageTable(attachedDatabase, alias); | ||||
|   } | ||||
|  | ||||
|   static JsonTypeConverter2<SnChatMessage, Uint8List, Object?> | ||||
|       $convertercontent = TypeConverter.jsonb( | ||||
|           fromJson: (json) => | ||||
|               SnChatMessage.fromJson(json as Map<String, Object?>), | ||||
|           toJson: (pref) => pref.toJson()); | ||||
| } | ||||
|  | ||||
| class SnLocalChatMessageData extends DataClass | ||||
|     implements Insertable<SnLocalChatMessageData> { | ||||
|   final int id; | ||||
|   final int channelId; | ||||
|   final SnChatMessage content; | ||||
|   final DateTime createdAt; | ||||
|   const SnLocalChatMessageData( | ||||
|       {required this.id, | ||||
|       required this.channelId, | ||||
|       required this.content, | ||||
|       required this.createdAt}); | ||||
|   @override | ||||
|   Map<String, Expression> toColumns(bool nullToAbsent) { | ||||
|     final map = <String, Expression>{}; | ||||
|     map['id'] = Variable<int>(id); | ||||
|     map['channel_id'] = Variable<int>(channelId); | ||||
|     { | ||||
|       map['content'] = Variable<Uint8List>( | ||||
|           $SnLocalChatMessageTable.$convertercontent.toSql(content)); | ||||
|     } | ||||
|     map['created_at'] = Variable<DateTime>(createdAt); | ||||
|     return map; | ||||
|   } | ||||
|  | ||||
|   SnLocalChatMessageCompanion toCompanion(bool nullToAbsent) { | ||||
|     return SnLocalChatMessageCompanion( | ||||
|       id: Value(id), | ||||
|       channelId: Value(channelId), | ||||
|       content: Value(content), | ||||
|       createdAt: Value(createdAt), | ||||
|     ); | ||||
|   } | ||||
|  | ||||
|   factory SnLocalChatMessageData.fromJson(Map<String, dynamic> json, | ||||
|       {ValueSerializer? serializer}) { | ||||
|     serializer ??= driftRuntimeOptions.defaultSerializer; | ||||
|     return SnLocalChatMessageData( | ||||
|       id: serializer.fromJson<int>(json['id']), | ||||
|       channelId: serializer.fromJson<int>(json['channelId']), | ||||
|       content: $SnLocalChatMessageTable.$convertercontent | ||||
|           .fromJson(serializer.fromJson<Object?>(json['content'])), | ||||
|       createdAt: serializer.fromJson<DateTime>(json['createdAt']), | ||||
|     ); | ||||
|   } | ||||
|   @override | ||||
|   Map<String, dynamic> toJson({ValueSerializer? serializer}) { | ||||
|     serializer ??= driftRuntimeOptions.defaultSerializer; | ||||
|     return <String, dynamic>{ | ||||
|       'id': serializer.toJson<int>(id), | ||||
|       'channelId': serializer.toJson<int>(channelId), | ||||
|       'content': serializer.toJson<Object?>( | ||||
|           $SnLocalChatMessageTable.$convertercontent.toJson(content)), | ||||
|       'createdAt': serializer.toJson<DateTime>(createdAt), | ||||
|     }; | ||||
|   } | ||||
|  | ||||
|   SnLocalChatMessageData copyWith( | ||||
|           {int? id, | ||||
|           int? channelId, | ||||
|           SnChatMessage? content, | ||||
|           DateTime? createdAt}) => | ||||
|       SnLocalChatMessageData( | ||||
|         id: id ?? this.id, | ||||
|         channelId: channelId ?? this.channelId, | ||||
|         content: content ?? this.content, | ||||
|         createdAt: createdAt ?? this.createdAt, | ||||
|       ); | ||||
|   SnLocalChatMessageData copyWithCompanion(SnLocalChatMessageCompanion data) { | ||||
|     return SnLocalChatMessageData( | ||||
|       id: data.id.present ? data.id.value : this.id, | ||||
|       channelId: data.channelId.present ? data.channelId.value : this.channelId, | ||||
|       content: data.content.present ? data.content.value : this.content, | ||||
|       createdAt: data.createdAt.present ? data.createdAt.value : this.createdAt, | ||||
|     ); | ||||
|   } | ||||
|  | ||||
|   @override | ||||
|   String toString() { | ||||
|     return (StringBuffer('SnLocalChatMessageData(') | ||||
|           ..write('id: $id, ') | ||||
|           ..write('channelId: $channelId, ') | ||||
|           ..write('content: $content, ') | ||||
|           ..write('createdAt: $createdAt') | ||||
|           ..write(')')) | ||||
|         .toString(); | ||||
|   } | ||||
|  | ||||
|   @override | ||||
|   int get hashCode => Object.hash(id, channelId, content, createdAt); | ||||
|   @override | ||||
|   bool operator ==(Object other) => | ||||
|       identical(this, other) || | ||||
|       (other is SnLocalChatMessageData && | ||||
|           other.id == this.id && | ||||
|           other.channelId == this.channelId && | ||||
|           other.content == this.content && | ||||
|           other.createdAt == this.createdAt); | ||||
| } | ||||
|  | ||||
| class SnLocalChatMessageCompanion | ||||
|     extends UpdateCompanion<SnLocalChatMessageData> { | ||||
|   final Value<int> id; | ||||
|   final Value<int> channelId; | ||||
|   final Value<SnChatMessage> content; | ||||
|   final Value<DateTime> createdAt; | ||||
|   const SnLocalChatMessageCompanion({ | ||||
|     this.id = const Value.absent(), | ||||
|     this.channelId = const Value.absent(), | ||||
|     this.content = const Value.absent(), | ||||
|     this.createdAt = const Value.absent(), | ||||
|   }); | ||||
|   SnLocalChatMessageCompanion.insert({ | ||||
|     this.id = const Value.absent(), | ||||
|     required int channelId, | ||||
|     required SnChatMessage content, | ||||
|     this.createdAt = const Value.absent(), | ||||
|   })  : channelId = Value(channelId), | ||||
|         content = Value(content); | ||||
|   static Insertable<SnLocalChatMessageData> custom({ | ||||
|     Expression<int>? id, | ||||
|     Expression<int>? channelId, | ||||
|     Expression<Uint8List>? content, | ||||
|     Expression<DateTime>? createdAt, | ||||
|   }) { | ||||
|     return RawValuesInsertable({ | ||||
|       if (id != null) 'id': id, | ||||
|       if (channelId != null) 'channel_id': channelId, | ||||
|       if (content != null) 'content': content, | ||||
|       if (createdAt != null) 'created_at': createdAt, | ||||
|     }); | ||||
|   } | ||||
|  | ||||
|   SnLocalChatMessageCompanion copyWith( | ||||
|       {Value<int>? id, | ||||
|       Value<int>? channelId, | ||||
|       Value<SnChatMessage>? content, | ||||
|       Value<DateTime>? createdAt}) { | ||||
|     return SnLocalChatMessageCompanion( | ||||
|       id: id ?? this.id, | ||||
|       channelId: channelId ?? this.channelId, | ||||
|       content: content ?? this.content, | ||||
|       createdAt: createdAt ?? this.createdAt, | ||||
|     ); | ||||
|   } | ||||
|  | ||||
|   @override | ||||
|   Map<String, Expression> toColumns(bool nullToAbsent) { | ||||
|     final map = <String, Expression>{}; | ||||
|     if (id.present) { | ||||
|       map['id'] = Variable<int>(id.value); | ||||
|     } | ||||
|     if (channelId.present) { | ||||
|       map['channel_id'] = Variable<int>(channelId.value); | ||||
|     } | ||||
|     if (content.present) { | ||||
|       map['content'] = Variable<Uint8List>( | ||||
|           $SnLocalChatMessageTable.$convertercontent.toSql(content.value)); | ||||
|     } | ||||
|     if (createdAt.present) { | ||||
|       map['created_at'] = Variable<DateTime>(createdAt.value); | ||||
|     } | ||||
|     return map; | ||||
|   } | ||||
|  | ||||
|   @override | ||||
|   String toString() { | ||||
|     return (StringBuffer('SnLocalChatMessageCompanion(') | ||||
|           ..write('id: $id, ') | ||||
|           ..write('channelId: $channelId, ') | ||||
|           ..write('content: $content, ') | ||||
|           ..write('createdAt: $createdAt') | ||||
|           ..write(')')) | ||||
|         .toString(); | ||||
|   } | ||||
| } | ||||
|  | ||||
| abstract class _$AppDatabase extends GeneratedDatabase { | ||||
|   _$AppDatabase(QueryExecutor e) : super(e); | ||||
|   $AppDatabaseManager get managers => $AppDatabaseManager(this); | ||||
|   late final $SnLocalChatChannelTable snLocalChatChannel = | ||||
|       $SnLocalChatChannelTable(this); | ||||
|   late final $SnLocalChatMessageTable snLocalChatMessage = | ||||
|       $SnLocalChatMessageTable(this); | ||||
|   @override | ||||
|   Iterable<TableInfo<Table, Object?>> get allTables => | ||||
|       allSchemaEntities.whereType<TableInfo<Table, Object?>>(); | ||||
|   @override | ||||
|   List<DatabaseSchemaEntity> get allSchemaEntities => | ||||
|       [snLocalChatChannel, snLocalChatMessage]; | ||||
| } | ||||
|  | ||||
| typedef $$SnLocalChatChannelTableCreateCompanionBuilder | ||||
|     = SnLocalChatChannelCompanion Function({ | ||||
|   Value<int> id, | ||||
|   required SnChannel content, | ||||
|   Value<DateTime> createdAt, | ||||
| }); | ||||
| typedef $$SnLocalChatChannelTableUpdateCompanionBuilder | ||||
|     = SnLocalChatChannelCompanion Function({ | ||||
|   Value<int> id, | ||||
|   Value<SnChannel> content, | ||||
|   Value<DateTime> createdAt, | ||||
| }); | ||||
|  | ||||
| class $$SnLocalChatChannelTableFilterComposer | ||||
|     extends Composer<_$AppDatabase, $SnLocalChatChannelTable> { | ||||
|   $$SnLocalChatChannelTableFilterComposer({ | ||||
|     required super.$db, | ||||
|     required super.$table, | ||||
|     super.joinBuilder, | ||||
|     super.$addJoinBuilderToRootComposer, | ||||
|     super.$removeJoinBuilderFromRootComposer, | ||||
|   }); | ||||
|   ColumnFilters<int> get id => $composableBuilder( | ||||
|       column: $table.id, builder: (column) => ColumnFilters(column)); | ||||
|  | ||||
|   ColumnWithTypeConverterFilters<SnChannel, SnChannel, Uint8List> get content => | ||||
|       $composableBuilder( | ||||
|           column: $table.content, | ||||
|           builder: (column) => ColumnWithTypeConverterFilters(column)); | ||||
|  | ||||
|   ColumnFilters<DateTime> get createdAt => $composableBuilder( | ||||
|       column: $table.createdAt, builder: (column) => ColumnFilters(column)); | ||||
| } | ||||
|  | ||||
| class $$SnLocalChatChannelTableOrderingComposer | ||||
|     extends Composer<_$AppDatabase, $SnLocalChatChannelTable> { | ||||
|   $$SnLocalChatChannelTableOrderingComposer({ | ||||
|     required super.$db, | ||||
|     required super.$table, | ||||
|     super.joinBuilder, | ||||
|     super.$addJoinBuilderToRootComposer, | ||||
|     super.$removeJoinBuilderFromRootComposer, | ||||
|   }); | ||||
|   ColumnOrderings<int> get id => $composableBuilder( | ||||
|       column: $table.id, builder: (column) => ColumnOrderings(column)); | ||||
|  | ||||
|   ColumnOrderings<Uint8List> get content => $composableBuilder( | ||||
|       column: $table.content, builder: (column) => ColumnOrderings(column)); | ||||
|  | ||||
|   ColumnOrderings<DateTime> get createdAt => $composableBuilder( | ||||
|       column: $table.createdAt, builder: (column) => ColumnOrderings(column)); | ||||
| } | ||||
|  | ||||
| class $$SnLocalChatChannelTableAnnotationComposer | ||||
|     extends Composer<_$AppDatabase, $SnLocalChatChannelTable> { | ||||
|   $$SnLocalChatChannelTableAnnotationComposer({ | ||||
|     required super.$db, | ||||
|     required super.$table, | ||||
|     super.joinBuilder, | ||||
|     super.$addJoinBuilderToRootComposer, | ||||
|     super.$removeJoinBuilderFromRootComposer, | ||||
|   }); | ||||
|   GeneratedColumn<int> get id => | ||||
|       $composableBuilder(column: $table.id, builder: (column) => column); | ||||
|  | ||||
|   GeneratedColumnWithTypeConverter<SnChannel, Uint8List> get content => | ||||
|       $composableBuilder(column: $table.content, builder: (column) => column); | ||||
|  | ||||
|   GeneratedColumn<DateTime> get createdAt => | ||||
|       $composableBuilder(column: $table.createdAt, builder: (column) => column); | ||||
| } | ||||
|  | ||||
| class $$SnLocalChatChannelTableTableManager extends RootTableManager< | ||||
|     _$AppDatabase, | ||||
|     $SnLocalChatChannelTable, | ||||
|     SnLocalChatChannelData, | ||||
|     $$SnLocalChatChannelTableFilterComposer, | ||||
|     $$SnLocalChatChannelTableOrderingComposer, | ||||
|     $$SnLocalChatChannelTableAnnotationComposer, | ||||
|     $$SnLocalChatChannelTableCreateCompanionBuilder, | ||||
|     $$SnLocalChatChannelTableUpdateCompanionBuilder, | ||||
|     ( | ||||
|       SnLocalChatChannelData, | ||||
|       BaseReferences<_$AppDatabase, $SnLocalChatChannelTable, | ||||
|           SnLocalChatChannelData> | ||||
|     ), | ||||
|     SnLocalChatChannelData, | ||||
|     PrefetchHooks Function()> { | ||||
|   $$SnLocalChatChannelTableTableManager( | ||||
|       _$AppDatabase db, $SnLocalChatChannelTable table) | ||||
|       : super(TableManagerState( | ||||
|           db: db, | ||||
|           table: table, | ||||
|           createFilteringComposer: () => | ||||
|               $$SnLocalChatChannelTableFilterComposer($db: db, $table: table), | ||||
|           createOrderingComposer: () => | ||||
|               $$SnLocalChatChannelTableOrderingComposer($db: db, $table: table), | ||||
|           createComputedFieldComposer: () => | ||||
|               $$SnLocalChatChannelTableAnnotationComposer( | ||||
|                   $db: db, $table: table), | ||||
|           updateCompanionCallback: ({ | ||||
|             Value<int> id = const Value.absent(), | ||||
|             Value<SnChannel> content = const Value.absent(), | ||||
|             Value<DateTime> createdAt = const Value.absent(), | ||||
|           }) => | ||||
|               SnLocalChatChannelCompanion( | ||||
|             id: id, | ||||
|             content: content, | ||||
|             createdAt: createdAt, | ||||
|           ), | ||||
|           createCompanionCallback: ({ | ||||
|             Value<int> id = const Value.absent(), | ||||
|             required SnChannel content, | ||||
|             Value<DateTime> createdAt = const Value.absent(), | ||||
|           }) => | ||||
|               SnLocalChatChannelCompanion.insert( | ||||
|             id: id, | ||||
|             content: content, | ||||
|             createdAt: createdAt, | ||||
|           ), | ||||
|           withReferenceMapper: (p0) => p0 | ||||
|               .map((e) => (e.readTable(table), BaseReferences(db, table, e))) | ||||
|               .toList(), | ||||
|           prefetchHooksCallback: null, | ||||
|         )); | ||||
| } | ||||
|  | ||||
| typedef $$SnLocalChatChannelTableProcessedTableManager = ProcessedTableManager< | ||||
|     _$AppDatabase, | ||||
|     $SnLocalChatChannelTable, | ||||
|     SnLocalChatChannelData, | ||||
|     $$SnLocalChatChannelTableFilterComposer, | ||||
|     $$SnLocalChatChannelTableOrderingComposer, | ||||
|     $$SnLocalChatChannelTableAnnotationComposer, | ||||
|     $$SnLocalChatChannelTableCreateCompanionBuilder, | ||||
|     $$SnLocalChatChannelTableUpdateCompanionBuilder, | ||||
|     ( | ||||
|       SnLocalChatChannelData, | ||||
|       BaseReferences<_$AppDatabase, $SnLocalChatChannelTable, | ||||
|           SnLocalChatChannelData> | ||||
|     ), | ||||
|     SnLocalChatChannelData, | ||||
|     PrefetchHooks Function()>; | ||||
| typedef $$SnLocalChatMessageTableCreateCompanionBuilder | ||||
|     = SnLocalChatMessageCompanion Function({ | ||||
|   Value<int> id, | ||||
|   required int channelId, | ||||
|   required SnChatMessage content, | ||||
|   Value<DateTime> createdAt, | ||||
| }); | ||||
| typedef $$SnLocalChatMessageTableUpdateCompanionBuilder | ||||
|     = SnLocalChatMessageCompanion Function({ | ||||
|   Value<int> id, | ||||
|   Value<int> channelId, | ||||
|   Value<SnChatMessage> content, | ||||
|   Value<DateTime> createdAt, | ||||
| }); | ||||
|  | ||||
| class $$SnLocalChatMessageTableFilterComposer | ||||
|     extends Composer<_$AppDatabase, $SnLocalChatMessageTable> { | ||||
|   $$SnLocalChatMessageTableFilterComposer({ | ||||
|     required super.$db, | ||||
|     required super.$table, | ||||
|     super.joinBuilder, | ||||
|     super.$addJoinBuilderToRootComposer, | ||||
|     super.$removeJoinBuilderFromRootComposer, | ||||
|   }); | ||||
|   ColumnFilters<int> get id => $composableBuilder( | ||||
|       column: $table.id, builder: (column) => ColumnFilters(column)); | ||||
|  | ||||
|   ColumnFilters<int> get channelId => $composableBuilder( | ||||
|       column: $table.channelId, builder: (column) => ColumnFilters(column)); | ||||
|  | ||||
|   ColumnWithTypeConverterFilters<SnChatMessage, SnChatMessage, Uint8List> | ||||
|       get content => $composableBuilder( | ||||
|           column: $table.content, | ||||
|           builder: (column) => ColumnWithTypeConverterFilters(column)); | ||||
|  | ||||
|   ColumnFilters<DateTime> get createdAt => $composableBuilder( | ||||
|       column: $table.createdAt, builder: (column) => ColumnFilters(column)); | ||||
| } | ||||
|  | ||||
| class $$SnLocalChatMessageTableOrderingComposer | ||||
|     extends Composer<_$AppDatabase, $SnLocalChatMessageTable> { | ||||
|   $$SnLocalChatMessageTableOrderingComposer({ | ||||
|     required super.$db, | ||||
|     required super.$table, | ||||
|     super.joinBuilder, | ||||
|     super.$addJoinBuilderToRootComposer, | ||||
|     super.$removeJoinBuilderFromRootComposer, | ||||
|   }); | ||||
|   ColumnOrderings<int> get id => $composableBuilder( | ||||
|       column: $table.id, builder: (column) => ColumnOrderings(column)); | ||||
|  | ||||
|   ColumnOrderings<int> get channelId => $composableBuilder( | ||||
|       column: $table.channelId, builder: (column) => ColumnOrderings(column)); | ||||
|  | ||||
|   ColumnOrderings<Uint8List> get content => $composableBuilder( | ||||
|       column: $table.content, builder: (column) => ColumnOrderings(column)); | ||||
|  | ||||
|   ColumnOrderings<DateTime> get createdAt => $composableBuilder( | ||||
|       column: $table.createdAt, builder: (column) => ColumnOrderings(column)); | ||||
| } | ||||
|  | ||||
| class $$SnLocalChatMessageTableAnnotationComposer | ||||
|     extends Composer<_$AppDatabase, $SnLocalChatMessageTable> { | ||||
|   $$SnLocalChatMessageTableAnnotationComposer({ | ||||
|     required super.$db, | ||||
|     required super.$table, | ||||
|     super.joinBuilder, | ||||
|     super.$addJoinBuilderToRootComposer, | ||||
|     super.$removeJoinBuilderFromRootComposer, | ||||
|   }); | ||||
|   GeneratedColumn<int> get id => | ||||
|       $composableBuilder(column: $table.id, builder: (column) => column); | ||||
|  | ||||
|   GeneratedColumn<int> get channelId => | ||||
|       $composableBuilder(column: $table.channelId, builder: (column) => column); | ||||
|  | ||||
|   GeneratedColumnWithTypeConverter<SnChatMessage, Uint8List> get content => | ||||
|       $composableBuilder(column: $table.content, builder: (column) => column); | ||||
|  | ||||
|   GeneratedColumn<DateTime> get createdAt => | ||||
|       $composableBuilder(column: $table.createdAt, builder: (column) => column); | ||||
| } | ||||
|  | ||||
| class $$SnLocalChatMessageTableTableManager extends RootTableManager< | ||||
|     _$AppDatabase, | ||||
|     $SnLocalChatMessageTable, | ||||
|     SnLocalChatMessageData, | ||||
|     $$SnLocalChatMessageTableFilterComposer, | ||||
|     $$SnLocalChatMessageTableOrderingComposer, | ||||
|     $$SnLocalChatMessageTableAnnotationComposer, | ||||
|     $$SnLocalChatMessageTableCreateCompanionBuilder, | ||||
|     $$SnLocalChatMessageTableUpdateCompanionBuilder, | ||||
|     ( | ||||
|       SnLocalChatMessageData, | ||||
|       BaseReferences<_$AppDatabase, $SnLocalChatMessageTable, | ||||
|           SnLocalChatMessageData> | ||||
|     ), | ||||
|     SnLocalChatMessageData, | ||||
|     PrefetchHooks Function()> { | ||||
|   $$SnLocalChatMessageTableTableManager( | ||||
|       _$AppDatabase db, $SnLocalChatMessageTable table) | ||||
|       : super(TableManagerState( | ||||
|           db: db, | ||||
|           table: table, | ||||
|           createFilteringComposer: () => | ||||
|               $$SnLocalChatMessageTableFilterComposer($db: db, $table: table), | ||||
|           createOrderingComposer: () => | ||||
|               $$SnLocalChatMessageTableOrderingComposer($db: db, $table: table), | ||||
|           createComputedFieldComposer: () => | ||||
|               $$SnLocalChatMessageTableAnnotationComposer( | ||||
|                   $db: db, $table: table), | ||||
|           updateCompanionCallback: ({ | ||||
|             Value<int> id = const Value.absent(), | ||||
|             Value<int> channelId = const Value.absent(), | ||||
|             Value<SnChatMessage> content = const Value.absent(), | ||||
|             Value<DateTime> createdAt = const Value.absent(), | ||||
|           }) => | ||||
|               SnLocalChatMessageCompanion( | ||||
|             id: id, | ||||
|             channelId: channelId, | ||||
|             content: content, | ||||
|             createdAt: createdAt, | ||||
|           ), | ||||
|           createCompanionCallback: ({ | ||||
|             Value<int> id = const Value.absent(), | ||||
|             required int channelId, | ||||
|             required SnChatMessage content, | ||||
|             Value<DateTime> createdAt = const Value.absent(), | ||||
|           }) => | ||||
|               SnLocalChatMessageCompanion.insert( | ||||
|             id: id, | ||||
|             channelId: channelId, | ||||
|             content: content, | ||||
|             createdAt: createdAt, | ||||
|           ), | ||||
|           withReferenceMapper: (p0) => p0 | ||||
|               .map((e) => (e.readTable(table), BaseReferences(db, table, e))) | ||||
|               .toList(), | ||||
|           prefetchHooksCallback: null, | ||||
|         )); | ||||
| } | ||||
|  | ||||
| typedef $$SnLocalChatMessageTableProcessedTableManager = ProcessedTableManager< | ||||
|     _$AppDatabase, | ||||
|     $SnLocalChatMessageTable, | ||||
|     SnLocalChatMessageData, | ||||
|     $$SnLocalChatMessageTableFilterComposer, | ||||
|     $$SnLocalChatMessageTableOrderingComposer, | ||||
|     $$SnLocalChatMessageTableAnnotationComposer, | ||||
|     $$SnLocalChatMessageTableCreateCompanionBuilder, | ||||
|     $$SnLocalChatMessageTableUpdateCompanionBuilder, | ||||
|     ( | ||||
|       SnLocalChatMessageData, | ||||
|       BaseReferences<_$AppDatabase, $SnLocalChatMessageTable, | ||||
|           SnLocalChatMessageData> | ||||
|     ), | ||||
|     SnLocalChatMessageData, | ||||
|     PrefetchHooks Function()>; | ||||
|  | ||||
| class $AppDatabaseManager { | ||||
|   final _$AppDatabase _db; | ||||
|   $AppDatabaseManager(this._db); | ||||
|   $$SnLocalChatChannelTableTableManager get snLocalChatChannel => | ||||
|       $$SnLocalChatChannelTableTableManager(_db, _db.snLocalChatChannel); | ||||
|   $$SnLocalChatMessageTableTableManager get snLocalChatMessage => | ||||
|       $$SnLocalChatMessageTableTableManager(_db, _db.snLocalChatMessage); | ||||
| } | ||||
							
								
								
									
										8
									
								
								lib/database/drift_worker.dart
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										8
									
								
								lib/database/drift_worker.dart
									
									
									
									
									
										Normal file
									
								
							| @@ -0,0 +1,8 @@ | ||||
| import 'package:drift/wasm.dart'; | ||||
|  | ||||
| // Use `dart compile js -O4 ./drift_worker.dart` to compile this file. | ||||
| // And place it in the web/ directory. | ||||
|  | ||||
| // When compiled with dart2js, this file defines a dedicated or shared web | ||||
| // worker used by drift. | ||||
| void main() => WasmDatabase.workerMainForOpen(); | ||||
| @@ -24,6 +24,7 @@ import 'package:surface/firebase_options.dart'; | ||||
| import 'package:surface/providers/channel.dart'; | ||||
| import 'package:surface/providers/chat_call.dart'; | ||||
| import 'package:surface/providers/config.dart'; | ||||
| import 'package:surface/providers/database.dart'; | ||||
| import 'package:surface/providers/link_preview.dart'; | ||||
| import 'package:surface/providers/navigation.dart'; | ||||
| import 'package:surface/providers/notification.dart'; | ||||
| @@ -142,6 +143,9 @@ class SolianApp extends StatelessWidget { | ||||
|         assetLoader: JsonAssetLoader(), | ||||
|         child: MultiProvider( | ||||
|           providers: [ | ||||
|             // Infrastructure layer | ||||
|             Provider(create: (ctx) => DatabaseProvider(ctx)), | ||||
|  | ||||
|             // System extensions layer | ||||
|             Provider(create: (ctx) => HomeWidgetProvider(ctx)), | ||||
|  | ||||
|   | ||||
							
								
								
									
										10
									
								
								lib/providers/database.dart
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										10
									
								
								lib/providers/database.dart
									
									
									
									
									
										Normal file
									
								
							| @@ -0,0 +1,10 @@ | ||||
| import 'package:flutter/material.dart'; | ||||
| import 'package:surface/database/database.dart'; | ||||
|  | ||||
| class DatabaseProvider { | ||||
|   late final AppDatabase db; | ||||
|  | ||||
|   DatabaseProvider(BuildContext context) { | ||||
|     db = AppDatabase(); | ||||
|   } | ||||
| } | ||||
| @@ -243,7 +243,12 @@ class _ExploreScreenState extends State<ExploreScreen> with SingleTickerProvider | ||||
|                         children: [ | ||||
|                           Icon(Symbols.globe, size: 20, color: Theme.of(context).appBarTheme.foregroundColor), | ||||
|                           const Gap(8), | ||||
|                           Text('postChannelGlobal').tr().textColor(Theme.of(context).appBarTheme.foregroundColor), | ||||
|                           Expanded( | ||||
|                             child: Text( | ||||
|                               'postChannelGlobal', | ||||
|                               maxLines: 1, | ||||
|                             ).tr().textColor(Theme.of(context).appBarTheme.foregroundColor), | ||||
|                           ), | ||||
|                         ], | ||||
|                       ), | ||||
|                     ), | ||||
| @@ -254,7 +259,12 @@ class _ExploreScreenState extends State<ExploreScreen> with SingleTickerProvider | ||||
|                         children: [ | ||||
|                           Icon(Symbols.group, size: 20, color: Theme.of(context).appBarTheme.foregroundColor), | ||||
|                           const Gap(8), | ||||
|                           Text('postChannelFriends').tr().textColor(Theme.of(context).appBarTheme.foregroundColor), | ||||
|                           Expanded( | ||||
|                             child: Text( | ||||
|                               'postChannelFriends', | ||||
|                               maxLines: 1, | ||||
|                             ).tr().textColor(Theme.of(context).appBarTheme.foregroundColor), | ||||
|                           ), | ||||
|                         ], | ||||
|                       ), | ||||
|                     ), | ||||
| @@ -265,7 +275,12 @@ class _ExploreScreenState extends State<ExploreScreen> with SingleTickerProvider | ||||
|                         children: [ | ||||
|                           Icon(Symbols.subscriptions, size: 20, color: Theme.of(context).appBarTheme.foregroundColor), | ||||
|                           const Gap(8), | ||||
|                           Text('postChannelFollowing').tr().textColor(Theme.of(context).appBarTheme.foregroundColor), | ||||
|                           Expanded( | ||||
|                             child: Text( | ||||
|                               'postChannelFollowing', | ||||
|                               maxLines: 1, | ||||
|                             ).tr().textColor(Theme.of(context).appBarTheme.foregroundColor), | ||||
|                           ), | ||||
|                         ], | ||||
|                       ), | ||||
|                     ), | ||||
| @@ -276,7 +291,12 @@ class _ExploreScreenState extends State<ExploreScreen> with SingleTickerProvider | ||||
|                         children: [ | ||||
|                           Icon(Symbols.workspaces, size: 20, color: Theme.of(context).appBarTheme.foregroundColor), | ||||
|                           const Gap(8), | ||||
|                           Text('postChannelRealm').tr().textColor(Theme.of(context).appBarTheme.foregroundColor), | ||||
|                           Expanded( | ||||
|                             child: Text( | ||||
|                               'postChannelRealm', | ||||
|                               maxLines: 1, | ||||
|                             ).tr().textColor(Theme.of(context).appBarTheme.foregroundColor), | ||||
|                           ), | ||||
|                         ], | ||||
|                       ), | ||||
|                     ), | ||||
|   | ||||
| @@ -15,6 +15,7 @@ | ||||
| #include <media_kit_libs_linux/media_kit_libs_linux_plugin.h> | ||||
| #include <media_kit_video/media_kit_video_plugin.h> | ||||
| #include <pasteboard/pasteboard_plugin.h> | ||||
| #include <sqlite3_flutter_libs/sqlite3_flutter_libs_plugin.h> | ||||
| #include <tray_manager/tray_manager_plugin.h> | ||||
| #include <url_launcher_linux/url_launcher_plugin.h> | ||||
|  | ||||
| @@ -46,6 +47,9 @@ void fl_register_plugins(FlPluginRegistry* registry) { | ||||
|   g_autoptr(FlPluginRegistrar) pasteboard_registrar = | ||||
|       fl_plugin_registry_get_registrar_for_plugin(registry, "PasteboardPlugin"); | ||||
|   pasteboard_plugin_register_with_registrar(pasteboard_registrar); | ||||
|   g_autoptr(FlPluginRegistrar) sqlite3_flutter_libs_registrar = | ||||
|       fl_plugin_registry_get_registrar_for_plugin(registry, "Sqlite3FlutterLibsPlugin"); | ||||
|   sqlite3_flutter_libs_plugin_register_with_registrar(sqlite3_flutter_libs_registrar); | ||||
|   g_autoptr(FlPluginRegistrar) tray_manager_registrar = | ||||
|       fl_plugin_registry_get_registrar_for_plugin(registry, "TrayManagerPlugin"); | ||||
|   tray_manager_plugin_register_with_registrar(tray_manager_registrar); | ||||
|   | ||||
| @@ -12,6 +12,7 @@ list(APPEND FLUTTER_PLUGIN_LIST | ||||
|   media_kit_libs_linux | ||||
|   media_kit_video | ||||
|   pasteboard | ||||
|   sqlite3_flutter_libs | ||||
|   tray_manager | ||||
|   url_launcher_linux | ||||
| ) | ||||
|   | ||||
| @@ -30,6 +30,7 @@ import screen_brightness_macos | ||||
| import share_plus | ||||
| import shared_preferences_foundation | ||||
| import sqflite_darwin | ||||
| import sqlite3_flutter_libs | ||||
| import tray_manager | ||||
| import url_launcher_macos | ||||
| import video_compress | ||||
| @@ -61,6 +62,7 @@ func RegisterGeneratedPlugins(registry: FlutterPluginRegistry) { | ||||
|   SharePlusMacosPlugin.register(with: registry.registrar(forPlugin: "SharePlusMacosPlugin")) | ||||
|   SharedPreferencesPlugin.register(with: registry.registrar(forPlugin: "SharedPreferencesPlugin")) | ||||
|   SqflitePlugin.register(with: registry.registrar(forPlugin: "SqflitePlugin")) | ||||
|   Sqlite3FlutterLibsPlugin.register(with: registry.registrar(forPlugin: "Sqlite3FlutterLibsPlugin")) | ||||
|   TrayManagerPlugin.register(with: registry.registrar(forPlugin: "TrayManagerPlugin")) | ||||
|   UrlLauncherPlugin.register(with: registry.registrar(forPlugin: "UrlLauncherPlugin")) | ||||
|   VideoCompressPlugin.register(with: registry.registrar(forPlugin: "VideoCompressPlugin")) | ||||
|   | ||||
							
								
								
									
										64
									
								
								pubspec.lock
									
									
									
									
									
								
							
							
						
						
									
										64
									
								
								pubspec.lock
									
									
									
									
									
								
							| @@ -230,6 +230,14 @@ packages: | ||||
|       url: "https://pub.dev" | ||||
|     source: hosted | ||||
|     version: "1.3.0" | ||||
|   charcode: | ||||
|     dependency: transitive | ||||
|     description: | ||||
|       name: charcode | ||||
|       sha256: fb0f1107cac15a5ea6ef0a6ef71a807b9e4267c713bb93e00e92d737cc8dbd8a | ||||
|       url: "https://pub.dev" | ||||
|     source: hosted | ||||
|     version: "1.4.0" | ||||
|   checked_yaml: | ||||
|     dependency: transitive | ||||
|     description: | ||||
| @@ -414,6 +422,30 @@ packages: | ||||
|       url: "https://pub.dev" | ||||
|     source: hosted | ||||
|     version: "1.0.2" | ||||
|   drift: | ||||
|     dependency: "direct main" | ||||
|     description: | ||||
|       name: drift | ||||
|       sha256: "97d5832657d49f26e7a8e07de397ddc63790b039372878d5117af816d0fdb5cb" | ||||
|       url: "https://pub.dev" | ||||
|     source: hosted | ||||
|     version: "2.25.1" | ||||
|   drift_dev: | ||||
|     dependency: "direct dev" | ||||
|     description: | ||||
|       name: drift_dev | ||||
|       sha256: f1db88482dbb016b9bbddddf746d5d0a6938b156ff20e07320052981f97388cc | ||||
|       url: "https://pub.dev" | ||||
|     source: hosted | ||||
|     version: "2.25.2" | ||||
|   drift_flutter: | ||||
|     dependency: "direct main" | ||||
|     description: | ||||
|       name: drift_flutter | ||||
|       sha256: "0cadbf3b8733409a6cf61d18ba2e94e149df81df7de26f48ae0695b48fd71922" | ||||
|       url: "https://pub.dev" | ||||
|     source: hosted | ||||
|     version: "0.2.4" | ||||
|   dropdown_button2: | ||||
|     dependency: "direct main" | ||||
|     description: | ||||
| @@ -1642,6 +1674,14 @@ packages: | ||||
|       url: "https://pub.dev" | ||||
|     source: hosted | ||||
|     version: "4.1.0" | ||||
|   recase: | ||||
|     dependency: transitive | ||||
|     description: | ||||
|       name: recase | ||||
|       sha256: e4eb4ec2dcdee52dcf99cb4ceabaffc631d7424ee55e56f280bc039737f89213 | ||||
|       url: "https://pub.dev" | ||||
|     source: hosted | ||||
|     version: "4.1.0" | ||||
|   receive_sharing_intent: | ||||
|     dependency: "direct main" | ||||
|     description: | ||||
| @@ -1935,6 +1975,30 @@ packages: | ||||
|       url: "https://pub.dev" | ||||
|     source: hosted | ||||
|     version: "2.4.0" | ||||
|   sqlite3: | ||||
|     dependency: transitive | ||||
|     description: | ||||
|       name: sqlite3 | ||||
|       sha256: "32b632dda27d664f85520093ed6f735ae5c49b5b75345afb8b19411bc59bb53d" | ||||
|       url: "https://pub.dev" | ||||
|     source: hosted | ||||
|     version: "2.7.4" | ||||
|   sqlite3_flutter_libs: | ||||
|     dependency: transitive | ||||
|     description: | ||||
|       name: sqlite3_flutter_libs | ||||
|       sha256: "57fafacd815c981735406215966ff7caaa8eab984b094f52e692accefcbd9233" | ||||
|       url: "https://pub.dev" | ||||
|     source: hosted | ||||
|     version: "0.5.30" | ||||
|   sqlparser: | ||||
|     dependency: transitive | ||||
|     description: | ||||
|       name: sqlparser | ||||
|       sha256: "27dd0a9f0c02e22ac0eb42a23df9ea079ce69b52bb4a3b478d64e0ef34a263ee" | ||||
|       url: "https://pub.dev" | ||||
|     source: hosted | ||||
|     version: "0.41.0" | ||||
|   stack_trace: | ||||
|     dependency: transitive | ||||
|     description: | ||||
|   | ||||
| @@ -123,6 +123,8 @@ dependencies: | ||||
|   image_picker_android: ^0.8.12+20 | ||||
|   cached_network_image_platform_interface: ^4.1.1 | ||||
|   image_picker_platform_interface: ^2.10.1 | ||||
|   drift: ^2.25.1 | ||||
|   drift_flutter: ^0.2.4 | ||||
|  | ||||
| dev_dependencies: | ||||
|   flutter_test: | ||||
| @@ -134,13 +136,14 @@ dev_dependencies: | ||||
|   # package. See that file for information about deactivating specific lint | ||||
|   # rules and activating additional ones. | ||||
|   flutter_lints: ^5.0.0 | ||||
|   build_runner: ^2.4.13 | ||||
|   build_runner: ^2.4.15 | ||||
|   freezed: ^2.5.7 | ||||
|   json_serializable: ^6.8.0 | ||||
|   icons_launcher: ^3.0.0 | ||||
|   flutter_native_splash: ^2.4.2 | ||||
|   hive_generator: ^2.0.1 | ||||
|   flutter_launcher_icons: ^0.14.1 | ||||
|   drift_dev: ^2.25.2 | ||||
|  | ||||
| # For information on the generic Dart part of this file, see the | ||||
| # following page: https://dart.dev/tools/pub/pubspec | ||||
|   | ||||
							
								
								
									
										13631
									
								
								web/drift_worker.dart.js
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										13631
									
								
								web/drift_worker.dart.js
									
									
									
									
									
										Normal file
									
								
							
										
											
												File diff suppressed because one or more lines are too long
											
										
									
								
							| @@ -1,11 +1,11 @@ | ||||
| { | ||||
|     "name": "surface", | ||||
|     "short_name": "surface", | ||||
|     "name": "Solar Network", | ||||
|     "short_name": "Solian", | ||||
|     "start_url": ".", | ||||
|     "display": "standalone", | ||||
|     "background_color": "#ffffff", | ||||
|     "theme_color": "#ffffff", | ||||
|     "description": "A new Flutter project.", | ||||
|     "description": "The Solar Network is a social network app.", | ||||
|     "orientation": "portrait-primary", | ||||
|     "prefer_related_applications": false, | ||||
|     "icons": [ | ||||
|   | ||||
							
								
								
									
										
											BIN
										
									
								
								web/sqlite3.wasm
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										
											BIN
										
									
								
								web/sqlite3.wasm
									
									
									
									
									
										Normal file
									
								
							
										
											Binary file not shown.
										
									
								
							| @@ -23,6 +23,7 @@ | ||||
| #include <permission_handler_windows/permission_handler_windows_plugin.h> | ||||
| #include <screen_brightness_windows/screen_brightness_windows_plugin.h> | ||||
| #include <share_plus/share_plus_windows_plugin_c_api.h> | ||||
| #include <sqlite3_flutter_libs/sqlite3_flutter_libs_plugin.h> | ||||
| #include <tray_manager/tray_manager_plugin.h> | ||||
| #include <url_launcher_windows/url_launcher_windows.h> | ||||
|  | ||||
| @@ -61,6 +62,8 @@ void RegisterPlugins(flutter::PluginRegistry* registry) { | ||||
|       registry->GetRegistrarForPlugin("ScreenBrightnessWindowsPlugin")); | ||||
|   SharePlusWindowsPluginCApiRegisterWithRegistrar( | ||||
|       registry->GetRegistrarForPlugin("SharePlusWindowsPluginCApi")); | ||||
|   Sqlite3FlutterLibsPluginRegisterWithRegistrar( | ||||
|       registry->GetRegistrarForPlugin("Sqlite3FlutterLibsPlugin")); | ||||
|   TrayManagerPluginRegisterWithRegistrar( | ||||
|       registry->GetRegistrarForPlugin("TrayManagerPlugin")); | ||||
|   UrlLauncherWindowsRegisterWithRegistrar( | ||||
|   | ||||
| @@ -20,6 +20,7 @@ list(APPEND FLUTTER_PLUGIN_LIST | ||||
|   permission_handler_windows | ||||
|   screen_brightness_windows | ||||
|   share_plus | ||||
|   sqlite3_flutter_libs | ||||
|   tray_manager | ||||
|   url_launcher_windows | ||||
| ) | ||||
|   | ||||
		Reference in New Issue
	
	Block a user