session and activity delete
This commit is contained in:
parent
3c2f2e9bae
commit
029f037f90
@ -15,6 +15,8 @@ class ActivitiesDao extends DatabaseAccessor<AppDatabase> with _$ActivitiesDaoMi
|
||||
return await (select(activities)..where((activity) => activity.id.equals(id) )).getSingle();
|
||||
}
|
||||
|
||||
Future remove(Activity activity) => delete(activities).delete(activity);
|
||||
|
||||
Future<List<Activity>> sessionActivities(int id) async {
|
||||
final result = select(db.sessionActivities).join(
|
||||
[
|
||||
|
@ -11,7 +11,17 @@ class SessionsDao extends DatabaseAccessor<AppDatabase> with _$SessionsDaoMixin
|
||||
return await select(sessions).get();
|
||||
}
|
||||
|
||||
// Future<List<Session>> remove
|
||||
|
||||
// Future<List<Session>> all() => select(sessions).get();
|
||||
// Stream<List<Session>> watch() => select(sessions).watch();
|
||||
// Future insert(Session session) => into(sessions).insert(session);
|
||||
// Future replace(Session session) => update(sessions).replace(session);
|
||||
Future remove(Session session) => delete(sessions).delete(session);
|
||||
|
||||
Future<Session> find(int id) async {
|
||||
return await (select(sessions)..where((session) => session.id.equals(id) )).getSingle();
|
||||
}
|
||||
|
||||
|
||||
}
|
@ -33,7 +33,7 @@ class AppDatabase extends _$AppDatabase {
|
||||
AppDatabase() : super(_openConnection());
|
||||
|
||||
@override
|
||||
int get schemaVersion => 4;
|
||||
int get schemaVersion => 6;
|
||||
|
||||
@override
|
||||
MigrationStrategy get migration {
|
||||
@ -64,6 +64,7 @@ class Sessions extends Table {
|
||||
TextColumn get title => text().withLength(min: 3, max: 32)();
|
||||
TextColumn get content => text().named('body')();
|
||||
TextColumn get status => textEnum<SessionStatus>()();
|
||||
TextColumn get address => text().withLength(min: 3, max: 256).nullable()();
|
||||
DateTimeColumn get date => dateTime().nullable()();
|
||||
DateTimeColumn get createdAt =>
|
||||
dateTime().withDefault(Variable(DateTime.now()))();
|
||||
@ -71,8 +72,8 @@ class Sessions extends Table {
|
||||
|
||||
class SessionActivities extends Table {
|
||||
IntColumn get id => integer().autoIncrement()();
|
||||
IntColumn get sessionId => integer().references(Sessions, #id)();
|
||||
IntColumn get activityId => integer().references(Activities, #id)();
|
||||
IntColumn get sessionId => integer().references(Sessions, #id, onDelete: KeyAction.cascade)();
|
||||
IntColumn get activityId => integer().references(Activities, #id, onDelete: KeyAction.cascade)();
|
||||
IntColumn get position => integer()();
|
||||
TextColumn get results => text().nullable()();
|
||||
TextColumn get achievements => text().nullable()();
|
||||
@ -107,8 +108,8 @@ class Activities extends Table {
|
||||
|
||||
class ActivityActions extends Table {
|
||||
IntColumn get id => integer().autoIncrement()();
|
||||
IntColumn get activityId => integer().references(Activities, #id)();
|
||||
IntColumn get actionId => integer().references(Actions, #id)();
|
||||
IntColumn get activityId => integer().references(Activities, #id, onDelete: KeyAction.cascade)();
|
||||
IntColumn get actionId => integer().references(Actions, #id, onDelete: KeyAction.cascade)();
|
||||
IntColumn get position => integer()();
|
||||
DateTimeColumn get createdAt =>
|
||||
dateTime().withDefault(Variable(DateTime.now()))();
|
||||
@ -133,7 +134,7 @@ class ObjectMediaItems extends Table {
|
||||
IntColumn get id => integer().autoIncrement()();
|
||||
IntColumn get objectId => integer()();
|
||||
TextColumn get objectType => textEnum<ObjectType>()();
|
||||
IntColumn get mediaId => integer().references(MediaItems, #id)();
|
||||
IntColumn get mediaId => integer().references(MediaItems, #id, onDelete: KeyAction.cascade)();
|
||||
DateTimeColumn get createdAt =>
|
||||
dateTime().withDefault(Variable(DateTime.now()))();
|
||||
}
|
||||
|
@ -37,6 +37,15 @@ class $SessionsTable extends Sessions with TableInfo<$SessionsTable, Session> {
|
||||
GeneratedColumn<String>('status', aliasedName, false,
|
||||
type: DriftSqlType.string, requiredDuringInsert: true)
|
||||
.withConverter<SessionStatus>($SessionsTable.$converterstatus);
|
||||
static const VerificationMeta _addressMeta =
|
||||
const VerificationMeta('address');
|
||||
@override
|
||||
late final GeneratedColumn<String> address = GeneratedColumn<String>(
|
||||
'address', aliasedName, true,
|
||||
additionalChecks:
|
||||
GeneratedColumn.checkTextLength(minTextLength: 3, maxTextLength: 256),
|
||||
type: DriftSqlType.string,
|
||||
requiredDuringInsert: false);
|
||||
static const VerificationMeta _dateMeta = const VerificationMeta('date');
|
||||
@override
|
||||
late final GeneratedColumn<DateTime> date = GeneratedColumn<DateTime>(
|
||||
@ -52,7 +61,7 @@ class $SessionsTable extends Sessions with TableInfo<$SessionsTable, Session> {
|
||||
defaultValue: Variable(DateTime.now()));
|
||||
@override
|
||||
List<GeneratedColumn> get $columns =>
|
||||
[id, title, content, status, date, createdAt];
|
||||
[id, title, content, status, address, date, createdAt];
|
||||
@override
|
||||
String get aliasedName => _alias ?? actualTableName;
|
||||
@override
|
||||
@ -79,6 +88,10 @@ class $SessionsTable extends Sessions with TableInfo<$SessionsTable, Session> {
|
||||
context.missing(_contentMeta);
|
||||
}
|
||||
context.handle(_statusMeta, const VerificationResult.success());
|
||||
if (data.containsKey('address')) {
|
||||
context.handle(_addressMeta,
|
||||
address.isAcceptableOrUnknown(data['address']!, _addressMeta));
|
||||
}
|
||||
if (data.containsKey('date')) {
|
||||
context.handle(
|
||||
_dateMeta, date.isAcceptableOrUnknown(data['date']!, _dateMeta));
|
||||
@ -105,6 +118,8 @@ class $SessionsTable extends Sessions with TableInfo<$SessionsTable, Session> {
|
||||
status: $SessionsTable.$converterstatus.fromSql(attachedDatabase
|
||||
.typeMapping
|
||||
.read(DriftSqlType.string, data['${effectivePrefix}status'])!),
|
||||
address: attachedDatabase.typeMapping
|
||||
.read(DriftSqlType.string, data['${effectivePrefix}address']),
|
||||
date: attachedDatabase.typeMapping
|
||||
.read(DriftSqlType.dateTime, data['${effectivePrefix}date']),
|
||||
createdAt: attachedDatabase.typeMapping
|
||||
@ -126,6 +141,7 @@ class Session extends DataClass implements Insertable<Session> {
|
||||
final String title;
|
||||
final String content;
|
||||
final SessionStatus status;
|
||||
final String? address;
|
||||
final DateTime? date;
|
||||
final DateTime createdAt;
|
||||
const Session(
|
||||
@ -133,6 +149,7 @@ class Session extends DataClass implements Insertable<Session> {
|
||||
required this.title,
|
||||
required this.content,
|
||||
required this.status,
|
||||
this.address,
|
||||
this.date,
|
||||
required this.createdAt});
|
||||
@override
|
||||
@ -145,6 +162,9 @@ class Session extends DataClass implements Insertable<Session> {
|
||||
map['status'] =
|
||||
Variable<String>($SessionsTable.$converterstatus.toSql(status));
|
||||
}
|
||||
if (!nullToAbsent || address != null) {
|
||||
map['address'] = Variable<String>(address);
|
||||
}
|
||||
if (!nullToAbsent || date != null) {
|
||||
map['date'] = Variable<DateTime>(date);
|
||||
}
|
||||
@ -158,6 +178,9 @@ class Session extends DataClass implements Insertable<Session> {
|
||||
title: Value(title),
|
||||
content: Value(content),
|
||||
status: Value(status),
|
||||
address: address == null && nullToAbsent
|
||||
? const Value.absent()
|
||||
: Value(address),
|
||||
date: date == null && nullToAbsent ? const Value.absent() : Value(date),
|
||||
createdAt: Value(createdAt),
|
||||
);
|
||||
@ -172,6 +195,7 @@ class Session extends DataClass implements Insertable<Session> {
|
||||
content: serializer.fromJson<String>(json['content']),
|
||||
status: $SessionsTable.$converterstatus
|
||||
.fromJson(serializer.fromJson<String>(json['status'])),
|
||||
address: serializer.fromJson<String?>(json['address']),
|
||||
date: serializer.fromJson<DateTime?>(json['date']),
|
||||
createdAt: serializer.fromJson<DateTime>(json['createdAt']),
|
||||
);
|
||||
@ -185,6 +209,7 @@ class Session extends DataClass implements Insertable<Session> {
|
||||
'content': serializer.toJson<String>(content),
|
||||
'status': serializer
|
||||
.toJson<String>($SessionsTable.$converterstatus.toJson(status)),
|
||||
'address': serializer.toJson<String?>(address),
|
||||
'date': serializer.toJson<DateTime?>(date),
|
||||
'createdAt': serializer.toJson<DateTime>(createdAt),
|
||||
};
|
||||
@ -195,6 +220,7 @@ class Session extends DataClass implements Insertable<Session> {
|
||||
String? title,
|
||||
String? content,
|
||||
SessionStatus? status,
|
||||
Value<String?> address = const Value.absent(),
|
||||
Value<DateTime?> date = const Value.absent(),
|
||||
DateTime? createdAt}) =>
|
||||
Session(
|
||||
@ -202,6 +228,7 @@ class Session extends DataClass implements Insertable<Session> {
|
||||
title: title ?? this.title,
|
||||
content: content ?? this.content,
|
||||
status: status ?? this.status,
|
||||
address: address.present ? address.value : this.address,
|
||||
date: date.present ? date.value : this.date,
|
||||
createdAt: createdAt ?? this.createdAt,
|
||||
);
|
||||
@ -211,6 +238,7 @@ class Session extends DataClass implements Insertable<Session> {
|
||||
title: data.title.present ? data.title.value : this.title,
|
||||
content: data.content.present ? data.content.value : this.content,
|
||||
status: data.status.present ? data.status.value : this.status,
|
||||
address: data.address.present ? data.address.value : this.address,
|
||||
date: data.date.present ? data.date.value : this.date,
|
||||
createdAt: data.createdAt.present ? data.createdAt.value : this.createdAt,
|
||||
);
|
||||
@ -223,6 +251,7 @@ class Session extends DataClass implements Insertable<Session> {
|
||||
..write('title: $title, ')
|
||||
..write('content: $content, ')
|
||||
..write('status: $status, ')
|
||||
..write('address: $address, ')
|
||||
..write('date: $date, ')
|
||||
..write('createdAt: $createdAt')
|
||||
..write(')'))
|
||||
@ -230,7 +259,8 @@ class Session extends DataClass implements Insertable<Session> {
|
||||
}
|
||||
|
||||
@override
|
||||
int get hashCode => Object.hash(id, title, content, status, date, createdAt);
|
||||
int get hashCode =>
|
||||
Object.hash(id, title, content, status, address, date, createdAt);
|
||||
@override
|
||||
bool operator ==(Object other) =>
|
||||
identical(this, other) ||
|
||||
@ -239,6 +269,7 @@ class Session extends DataClass implements Insertable<Session> {
|
||||
other.title == this.title &&
|
||||
other.content == this.content &&
|
||||
other.status == this.status &&
|
||||
other.address == this.address &&
|
||||
other.date == this.date &&
|
||||
other.createdAt == this.createdAt);
|
||||
}
|
||||
@ -248,6 +279,7 @@ class SessionsCompanion extends UpdateCompanion<Session> {
|
||||
final Value<String> title;
|
||||
final Value<String> content;
|
||||
final Value<SessionStatus> status;
|
||||
final Value<String?> address;
|
||||
final Value<DateTime?> date;
|
||||
final Value<DateTime> createdAt;
|
||||
const SessionsCompanion({
|
||||
@ -255,6 +287,7 @@ class SessionsCompanion extends UpdateCompanion<Session> {
|
||||
this.title = const Value.absent(),
|
||||
this.content = const Value.absent(),
|
||||
this.status = const Value.absent(),
|
||||
this.address = const Value.absent(),
|
||||
this.date = const Value.absent(),
|
||||
this.createdAt = const Value.absent(),
|
||||
});
|
||||
@ -263,6 +296,7 @@ class SessionsCompanion extends UpdateCompanion<Session> {
|
||||
required String title,
|
||||
required String content,
|
||||
required SessionStatus status,
|
||||
this.address = const Value.absent(),
|
||||
this.date = const Value.absent(),
|
||||
this.createdAt = const Value.absent(),
|
||||
}) : title = Value(title),
|
||||
@ -273,6 +307,7 @@ class SessionsCompanion extends UpdateCompanion<Session> {
|
||||
Expression<String>? title,
|
||||
Expression<String>? content,
|
||||
Expression<String>? status,
|
||||
Expression<String>? address,
|
||||
Expression<DateTime>? date,
|
||||
Expression<DateTime>? createdAt,
|
||||
}) {
|
||||
@ -281,6 +316,7 @@ class SessionsCompanion extends UpdateCompanion<Session> {
|
||||
if (title != null) 'title': title,
|
||||
if (content != null) 'body': content,
|
||||
if (status != null) 'status': status,
|
||||
if (address != null) 'address': address,
|
||||
if (date != null) 'date': date,
|
||||
if (createdAt != null) 'created_at': createdAt,
|
||||
});
|
||||
@ -291,6 +327,7 @@ class SessionsCompanion extends UpdateCompanion<Session> {
|
||||
Value<String>? title,
|
||||
Value<String>? content,
|
||||
Value<SessionStatus>? status,
|
||||
Value<String?>? address,
|
||||
Value<DateTime?>? date,
|
||||
Value<DateTime>? createdAt}) {
|
||||
return SessionsCompanion(
|
||||
@ -298,6 +335,7 @@ class SessionsCompanion extends UpdateCompanion<Session> {
|
||||
title: title ?? this.title,
|
||||
content: content ?? this.content,
|
||||
status: status ?? this.status,
|
||||
address: address ?? this.address,
|
||||
date: date ?? this.date,
|
||||
createdAt: createdAt ?? this.createdAt,
|
||||
);
|
||||
@ -319,6 +357,9 @@ class SessionsCompanion extends UpdateCompanion<Session> {
|
||||
map['status'] =
|
||||
Variable<String>($SessionsTable.$converterstatus.toSql(status.value));
|
||||
}
|
||||
if (address.present) {
|
||||
map['address'] = Variable<String>(address.value);
|
||||
}
|
||||
if (date.present) {
|
||||
map['date'] = Variable<DateTime>(date.value);
|
||||
}
|
||||
@ -335,6 +376,7 @@ class SessionsCompanion extends UpdateCompanion<Session> {
|
||||
..write('title: $title, ')
|
||||
..write('content: $content, ')
|
||||
..write('status: $status, ')
|
||||
..write('address: $address, ')
|
||||
..write('date: $date, ')
|
||||
..write('createdAt: $createdAt')
|
||||
..write(')'))
|
||||
@ -714,8 +756,8 @@ class $SessionActivitiesTable extends SessionActivities
|
||||
'session_id', aliasedName, false,
|
||||
type: DriftSqlType.int,
|
||||
requiredDuringInsert: true,
|
||||
defaultConstraints:
|
||||
GeneratedColumn.constraintIsAlways('REFERENCES sessions (id)'));
|
||||
defaultConstraints: GeneratedColumn.constraintIsAlways(
|
||||
'REFERENCES sessions (id) ON DELETE CASCADE'));
|
||||
static const VerificationMeta _activityIdMeta =
|
||||
const VerificationMeta('activityId');
|
||||
@override
|
||||
@ -723,8 +765,8 @@ class $SessionActivitiesTable extends SessionActivities
|
||||
'activity_id', aliasedName, false,
|
||||
type: DriftSqlType.int,
|
||||
requiredDuringInsert: true,
|
||||
defaultConstraints:
|
||||
GeneratedColumn.constraintIsAlways('REFERENCES activities (id)'));
|
||||
defaultConstraints: GeneratedColumn.constraintIsAlways(
|
||||
'REFERENCES activities (id) ON DELETE CASCADE'));
|
||||
static const VerificationMeta _positionMeta =
|
||||
const VerificationMeta('position');
|
||||
@override
|
||||
@ -1402,8 +1444,8 @@ class $ActivityActionsTable extends ActivityActions
|
||||
'activity_id', aliasedName, false,
|
||||
type: DriftSqlType.int,
|
||||
requiredDuringInsert: true,
|
||||
defaultConstraints:
|
||||
GeneratedColumn.constraintIsAlways('REFERENCES activities (id)'));
|
||||
defaultConstraints: GeneratedColumn.constraintIsAlways(
|
||||
'REFERENCES activities (id) ON DELETE CASCADE'));
|
||||
static const VerificationMeta _actionIdMeta =
|
||||
const VerificationMeta('actionId');
|
||||
@override
|
||||
@ -1411,8 +1453,8 @@ class $ActivityActionsTable extends ActivityActions
|
||||
'action_id', aliasedName, false,
|
||||
type: DriftSqlType.int,
|
||||
requiredDuringInsert: true,
|
||||
defaultConstraints:
|
||||
GeneratedColumn.constraintIsAlways('REFERENCES actions (id)'));
|
||||
defaultConstraints: GeneratedColumn.constraintIsAlways(
|
||||
'REFERENCES actions (id) ON DELETE CASCADE'));
|
||||
static const VerificationMeta _positionMeta =
|
||||
const VerificationMeta('position');
|
||||
@override
|
||||
@ -2070,8 +2112,8 @@ class $ObjectMediaItemsTable extends ObjectMediaItems
|
||||
'media_id', aliasedName, false,
|
||||
type: DriftSqlType.int,
|
||||
requiredDuringInsert: true,
|
||||
defaultConstraints:
|
||||
GeneratedColumn.constraintIsAlways('REFERENCES media_items (id)'));
|
||||
defaultConstraints: GeneratedColumn.constraintIsAlways(
|
||||
'REFERENCES media_items (id) ON DELETE CASCADE'));
|
||||
static const VerificationMeta _createdAtMeta =
|
||||
const VerificationMeta('createdAt');
|
||||
@override
|
||||
@ -2377,6 +2419,46 @@ abstract class _$AppDatabase extends GeneratedDatabase {
|
||||
mediaItems,
|
||||
objectMediaItems
|
||||
];
|
||||
@override
|
||||
StreamQueryUpdateRules get streamUpdateRules => const StreamQueryUpdateRules(
|
||||
[
|
||||
WritePropagation(
|
||||
on: TableUpdateQuery.onTableName('sessions',
|
||||
limitUpdateKind: UpdateKind.delete),
|
||||
result: [
|
||||
TableUpdate('session_activities', kind: UpdateKind.delete),
|
||||
],
|
||||
),
|
||||
WritePropagation(
|
||||
on: TableUpdateQuery.onTableName('activities',
|
||||
limitUpdateKind: UpdateKind.delete),
|
||||
result: [
|
||||
TableUpdate('session_activities', kind: UpdateKind.delete),
|
||||
],
|
||||
),
|
||||
WritePropagation(
|
||||
on: TableUpdateQuery.onTableName('activities',
|
||||
limitUpdateKind: UpdateKind.delete),
|
||||
result: [
|
||||
TableUpdate('activity_actions', kind: UpdateKind.delete),
|
||||
],
|
||||
),
|
||||
WritePropagation(
|
||||
on: TableUpdateQuery.onTableName('actions',
|
||||
limitUpdateKind: UpdateKind.delete),
|
||||
result: [
|
||||
TableUpdate('activity_actions', kind: UpdateKind.delete),
|
||||
],
|
||||
),
|
||||
WritePropagation(
|
||||
on: TableUpdateQuery.onTableName('media_items',
|
||||
limitUpdateKind: UpdateKind.delete),
|
||||
result: [
|
||||
TableUpdate('object_media_items', kind: UpdateKind.delete),
|
||||
],
|
||||
),
|
||||
],
|
||||
);
|
||||
}
|
||||
|
||||
typedef $$SessionsTableCreateCompanionBuilder = SessionsCompanion Function({
|
||||
@ -2384,6 +2466,7 @@ typedef $$SessionsTableCreateCompanionBuilder = SessionsCompanion Function({
|
||||
required String title,
|
||||
required String content,
|
||||
required SessionStatus status,
|
||||
Value<String?> address,
|
||||
Value<DateTime?> date,
|
||||
Value<DateTime> createdAt,
|
||||
});
|
||||
@ -2392,6 +2475,7 @@ typedef $$SessionsTableUpdateCompanionBuilder = SessionsCompanion Function({
|
||||
Value<String> title,
|
||||
Value<String> content,
|
||||
Value<SessionStatus> status,
|
||||
Value<String?> address,
|
||||
Value<DateTime?> date,
|
||||
Value<DateTime> createdAt,
|
||||
});
|
||||
@ -2441,6 +2525,9 @@ class $$SessionsTableFilterComposer
|
||||
column: $table.status,
|
||||
builder: (column) => ColumnWithTypeConverterFilters(column));
|
||||
|
||||
ColumnFilters<String> get address => $composableBuilder(
|
||||
column: $table.address, builder: (column) => ColumnFilters(column));
|
||||
|
||||
ColumnFilters<DateTime> get date => $composableBuilder(
|
||||
column: $table.date, builder: (column) => ColumnFilters(column));
|
||||
|
||||
@ -2490,6 +2577,9 @@ class $$SessionsTableOrderingComposer
|
||||
ColumnOrderings<String> get status => $composableBuilder(
|
||||
column: $table.status, builder: (column) => ColumnOrderings(column));
|
||||
|
||||
ColumnOrderings<String> get address => $composableBuilder(
|
||||
column: $table.address, builder: (column) => ColumnOrderings(column));
|
||||
|
||||
ColumnOrderings<DateTime> get date => $composableBuilder(
|
||||
column: $table.date, builder: (column) => ColumnOrderings(column));
|
||||
|
||||
@ -2518,6 +2608,9 @@ class $$SessionsTableAnnotationComposer
|
||||
GeneratedColumnWithTypeConverter<SessionStatus, String> get status =>
|
||||
$composableBuilder(column: $table.status, builder: (column) => column);
|
||||
|
||||
GeneratedColumn<String> get address =>
|
||||
$composableBuilder(column: $table.address, builder: (column) => column);
|
||||
|
||||
GeneratedColumn<DateTime> get date =>
|
||||
$composableBuilder(column: $table.date, builder: (column) => column);
|
||||
|
||||
@ -2574,6 +2667,7 @@ class $$SessionsTableTableManager extends RootTableManager<
|
||||
Value<String> title = const Value.absent(),
|
||||
Value<String> content = const Value.absent(),
|
||||
Value<SessionStatus> status = const Value.absent(),
|
||||
Value<String?> address = const Value.absent(),
|
||||
Value<DateTime?> date = const Value.absent(),
|
||||
Value<DateTime> createdAt = const Value.absent(),
|
||||
}) =>
|
||||
@ -2582,6 +2676,7 @@ class $$SessionsTableTableManager extends RootTableManager<
|
||||
title: title,
|
||||
content: content,
|
||||
status: status,
|
||||
address: address,
|
||||
date: date,
|
||||
createdAt: createdAt,
|
||||
),
|
||||
@ -2590,6 +2685,7 @@ class $$SessionsTableTableManager extends RootTableManager<
|
||||
required String title,
|
||||
required String content,
|
||||
required SessionStatus status,
|
||||
Value<String?> address = const Value.absent(),
|
||||
Value<DateTime?> date = const Value.absent(),
|
||||
Value<DateTime> createdAt = const Value.absent(),
|
||||
}) =>
|
||||
@ -2598,6 +2694,7 @@ class $$SessionsTableTableManager extends RootTableManager<
|
||||
title: title,
|
||||
content: content,
|
||||
status: status,
|
||||
address: address,
|
||||
date: date,
|
||||
createdAt: createdAt,
|
||||
),
|
||||
|
@ -647,10 +647,320 @@ class Shape10 extends i0.VersionedTable {
|
||||
columnsByName['created_at']! as i1.GeneratedColumn<DateTime>;
|
||||
}
|
||||
|
||||
final class Schema5 extends i0.VersionedSchema {
|
||||
Schema5({required super.database}) : super(version: 5);
|
||||
@override
|
||||
late final List<i1.DatabaseSchemaEntity> entities = [
|
||||
sessions,
|
||||
activities,
|
||||
sessionActivities,
|
||||
actions,
|
||||
activityActions,
|
||||
mediaItems,
|
||||
objectMediaItems,
|
||||
];
|
||||
late final Shape11 sessions = Shape11(
|
||||
source: i0.VersionedTable(
|
||||
entityName: 'sessions',
|
||||
withoutRowId: false,
|
||||
isStrict: false,
|
||||
tableConstraints: [],
|
||||
columns: [
|
||||
_column_0,
|
||||
_column_1,
|
||||
_column_2,
|
||||
_column_3,
|
||||
_column_20,
|
||||
_column_4,
|
||||
_column_5,
|
||||
],
|
||||
attachedDatabase: database,
|
||||
),
|
||||
alias: null);
|
||||
late final Shape1 activities = Shape1(
|
||||
source: i0.VersionedTable(
|
||||
entityName: 'activities',
|
||||
withoutRowId: false,
|
||||
isStrict: false,
|
||||
tableConstraints: [],
|
||||
columns: [
|
||||
_column_0,
|
||||
_column_1,
|
||||
_column_6,
|
||||
_column_2,
|
||||
_column_7,
|
||||
_column_5,
|
||||
],
|
||||
attachedDatabase: database,
|
||||
),
|
||||
alias: null);
|
||||
late final Shape9 sessionActivities = Shape9(
|
||||
source: i0.VersionedTable(
|
||||
entityName: 'session_activities',
|
||||
withoutRowId: false,
|
||||
isStrict: false,
|
||||
tableConstraints: [],
|
||||
columns: [
|
||||
_column_0,
|
||||
_column_8,
|
||||
_column_9,
|
||||
_column_19,
|
||||
_column_10,
|
||||
_column_11,
|
||||
_column_5,
|
||||
],
|
||||
attachedDatabase: database,
|
||||
),
|
||||
alias: null);
|
||||
late final Shape3 actions = Shape3(
|
||||
source: i0.VersionedTable(
|
||||
entityName: 'actions',
|
||||
withoutRowId: false,
|
||||
isStrict: false,
|
||||
tableConstraints: [],
|
||||
columns: [
|
||||
_column_0,
|
||||
_column_1,
|
||||
_column_2,
|
||||
_column_12,
|
||||
_column_5,
|
||||
],
|
||||
attachedDatabase: database,
|
||||
),
|
||||
alias: null);
|
||||
late final Shape10 activityActions = Shape10(
|
||||
source: i0.VersionedTable(
|
||||
entityName: 'activity_actions',
|
||||
withoutRowId: false,
|
||||
isStrict: false,
|
||||
tableConstraints: [],
|
||||
columns: [
|
||||
_column_0,
|
||||
_column_9,
|
||||
_column_13,
|
||||
_column_19,
|
||||
_column_5,
|
||||
],
|
||||
attachedDatabase: database,
|
||||
),
|
||||
alias: null);
|
||||
late final Shape5 mediaItems = Shape5(
|
||||
source: i0.VersionedTable(
|
||||
entityName: 'media_items',
|
||||
withoutRowId: false,
|
||||
isStrict: false,
|
||||
tableConstraints: [],
|
||||
columns: [
|
||||
_column_0,
|
||||
_column_1,
|
||||
_column_2,
|
||||
_column_14,
|
||||
_column_6,
|
||||
_column_5,
|
||||
],
|
||||
attachedDatabase: database,
|
||||
),
|
||||
alias: null);
|
||||
late final Shape6 objectMediaItems = Shape6(
|
||||
source: i0.VersionedTable(
|
||||
entityName: 'object_media_items',
|
||||
withoutRowId: false,
|
||||
isStrict: false,
|
||||
tableConstraints: [],
|
||||
columns: [
|
||||
_column_0,
|
||||
_column_15,
|
||||
_column_16,
|
||||
_column_17,
|
||||
_column_5,
|
||||
],
|
||||
attachedDatabase: database,
|
||||
),
|
||||
alias: null);
|
||||
}
|
||||
|
||||
class Shape11 extends i0.VersionedTable {
|
||||
Shape11({required super.source, required super.alias}) : super.aliased();
|
||||
i1.GeneratedColumn<int> get id =>
|
||||
columnsByName['id']! as i1.GeneratedColumn<int>;
|
||||
i1.GeneratedColumn<String> get title =>
|
||||
columnsByName['title']! as i1.GeneratedColumn<String>;
|
||||
i1.GeneratedColumn<String> get content =>
|
||||
columnsByName['body']! as i1.GeneratedColumn<String>;
|
||||
i1.GeneratedColumn<String> get status =>
|
||||
columnsByName['status']! as i1.GeneratedColumn<String>;
|
||||
i1.GeneratedColumn<String> get address =>
|
||||
columnsByName['address']! as i1.GeneratedColumn<String>;
|
||||
i1.GeneratedColumn<DateTime> get date =>
|
||||
columnsByName['date']! as i1.GeneratedColumn<DateTime>;
|
||||
i1.GeneratedColumn<DateTime> get createdAt =>
|
||||
columnsByName['created_at']! as i1.GeneratedColumn<DateTime>;
|
||||
}
|
||||
|
||||
i1.GeneratedColumn<String> _column_20(String aliasedName) =>
|
||||
i1.GeneratedColumn<String>('address', aliasedName, true,
|
||||
additionalChecks: i1.GeneratedColumn.checkTextLength(
|
||||
minTextLength: 3, maxTextLength: 256),
|
||||
type: i1.DriftSqlType.string);
|
||||
|
||||
final class Schema6 extends i0.VersionedSchema {
|
||||
Schema6({required super.database}) : super(version: 6);
|
||||
@override
|
||||
late final List<i1.DatabaseSchemaEntity> entities = [
|
||||
sessions,
|
||||
activities,
|
||||
sessionActivities,
|
||||
actions,
|
||||
activityActions,
|
||||
mediaItems,
|
||||
objectMediaItems,
|
||||
];
|
||||
late final Shape11 sessions = Shape11(
|
||||
source: i0.VersionedTable(
|
||||
entityName: 'sessions',
|
||||
withoutRowId: false,
|
||||
isStrict: false,
|
||||
tableConstraints: [],
|
||||
columns: [
|
||||
_column_0,
|
||||
_column_1,
|
||||
_column_2,
|
||||
_column_3,
|
||||
_column_20,
|
||||
_column_4,
|
||||
_column_5,
|
||||
],
|
||||
attachedDatabase: database,
|
||||
),
|
||||
alias: null);
|
||||
late final Shape1 activities = Shape1(
|
||||
source: i0.VersionedTable(
|
||||
entityName: 'activities',
|
||||
withoutRowId: false,
|
||||
isStrict: false,
|
||||
tableConstraints: [],
|
||||
columns: [
|
||||
_column_0,
|
||||
_column_1,
|
||||
_column_6,
|
||||
_column_2,
|
||||
_column_7,
|
||||
_column_5,
|
||||
],
|
||||
attachedDatabase: database,
|
||||
),
|
||||
alias: null);
|
||||
late final Shape9 sessionActivities = Shape9(
|
||||
source: i0.VersionedTable(
|
||||
entityName: 'session_activities',
|
||||
withoutRowId: false,
|
||||
isStrict: false,
|
||||
tableConstraints: [],
|
||||
columns: [
|
||||
_column_0,
|
||||
_column_21,
|
||||
_column_22,
|
||||
_column_19,
|
||||
_column_10,
|
||||
_column_11,
|
||||
_column_5,
|
||||
],
|
||||
attachedDatabase: database,
|
||||
),
|
||||
alias: null);
|
||||
late final Shape3 actions = Shape3(
|
||||
source: i0.VersionedTable(
|
||||
entityName: 'actions',
|
||||
withoutRowId: false,
|
||||
isStrict: false,
|
||||
tableConstraints: [],
|
||||
columns: [
|
||||
_column_0,
|
||||
_column_1,
|
||||
_column_2,
|
||||
_column_12,
|
||||
_column_5,
|
||||
],
|
||||
attachedDatabase: database,
|
||||
),
|
||||
alias: null);
|
||||
late final Shape10 activityActions = Shape10(
|
||||
source: i0.VersionedTable(
|
||||
entityName: 'activity_actions',
|
||||
withoutRowId: false,
|
||||
isStrict: false,
|
||||
tableConstraints: [],
|
||||
columns: [
|
||||
_column_0,
|
||||
_column_22,
|
||||
_column_23,
|
||||
_column_19,
|
||||
_column_5,
|
||||
],
|
||||
attachedDatabase: database,
|
||||
),
|
||||
alias: null);
|
||||
late final Shape5 mediaItems = Shape5(
|
||||
source: i0.VersionedTable(
|
||||
entityName: 'media_items',
|
||||
withoutRowId: false,
|
||||
isStrict: false,
|
||||
tableConstraints: [],
|
||||
columns: [
|
||||
_column_0,
|
||||
_column_1,
|
||||
_column_2,
|
||||
_column_14,
|
||||
_column_6,
|
||||
_column_5,
|
||||
],
|
||||
attachedDatabase: database,
|
||||
),
|
||||
alias: null);
|
||||
late final Shape6 objectMediaItems = Shape6(
|
||||
source: i0.VersionedTable(
|
||||
entityName: 'object_media_items',
|
||||
withoutRowId: false,
|
||||
isStrict: false,
|
||||
tableConstraints: [],
|
||||
columns: [
|
||||
_column_0,
|
||||
_column_15,
|
||||
_column_16,
|
||||
_column_24,
|
||||
_column_5,
|
||||
],
|
||||
attachedDatabase: database,
|
||||
),
|
||||
alias: null);
|
||||
}
|
||||
|
||||
i1.GeneratedColumn<int> _column_21(String aliasedName) =>
|
||||
i1.GeneratedColumn<int>('session_id', aliasedName, false,
|
||||
type: i1.DriftSqlType.int,
|
||||
defaultConstraints: i1.GeneratedColumn.constraintIsAlways(
|
||||
'REFERENCES sessions (id) ON DELETE CASCADE'));
|
||||
i1.GeneratedColumn<int> _column_22(String aliasedName) =>
|
||||
i1.GeneratedColumn<int>('activity_id', aliasedName, false,
|
||||
type: i1.DriftSqlType.int,
|
||||
defaultConstraints: i1.GeneratedColumn.constraintIsAlways(
|
||||
'REFERENCES activities (id) ON DELETE CASCADE'));
|
||||
i1.GeneratedColumn<int> _column_23(String aliasedName) =>
|
||||
i1.GeneratedColumn<int>('action_id', aliasedName, false,
|
||||
type: i1.DriftSqlType.int,
|
||||
defaultConstraints: i1.GeneratedColumn.constraintIsAlways(
|
||||
'REFERENCES actions (id) ON DELETE CASCADE'));
|
||||
i1.GeneratedColumn<int> _column_24(String aliasedName) =>
|
||||
i1.GeneratedColumn<int>('media_id', aliasedName, false,
|
||||
type: i1.DriftSqlType.int,
|
||||
defaultConstraints: i1.GeneratedColumn.constraintIsAlways(
|
||||
'REFERENCES media_items (id) ON DELETE CASCADE'));
|
||||
i0.MigrationStepWithVersion migrationSteps({
|
||||
required Future<void> Function(i1.Migrator m, Schema2 schema) from1To2,
|
||||
required Future<void> Function(i1.Migrator m, Schema3 schema) from2To3,
|
||||
required Future<void> Function(i1.Migrator m, Schema4 schema) from3To4,
|
||||
required Future<void> Function(i1.Migrator m, Schema5 schema) from4To5,
|
||||
required Future<void> Function(i1.Migrator m, Schema6 schema) from5To6,
|
||||
}) {
|
||||
return (currentVersion, database) async {
|
||||
switch (currentVersion) {
|
||||
@ -669,6 +979,16 @@ i0.MigrationStepWithVersion migrationSteps({
|
||||
final migrator = i1.Migrator(database, schema);
|
||||
await from3To4(migrator, schema);
|
||||
return 4;
|
||||
case 4:
|
||||
final schema = Schema5(database: database);
|
||||
final migrator = i1.Migrator(database, schema);
|
||||
await from4To5(migrator, schema);
|
||||
return 5;
|
||||
case 5:
|
||||
final schema = Schema6(database: database);
|
||||
final migrator = i1.Migrator(database, schema);
|
||||
await from5To6(migrator, schema);
|
||||
return 6;
|
||||
default:
|
||||
throw ArgumentError.value('Unknown migration from $currentVersion');
|
||||
}
|
||||
@ -679,10 +999,14 @@ i1.OnUpgrade stepByStep({
|
||||
required Future<void> Function(i1.Migrator m, Schema2 schema) from1To2,
|
||||
required Future<void> Function(i1.Migrator m, Schema3 schema) from2To3,
|
||||
required Future<void> Function(i1.Migrator m, Schema4 schema) from3To4,
|
||||
required Future<void> Function(i1.Migrator m, Schema5 schema) from4To5,
|
||||
required Future<void> Function(i1.Migrator m, Schema6 schema) from5To6,
|
||||
}) =>
|
||||
i0.VersionedSchema.stepByStepHelper(
|
||||
step: migrationSteps(
|
||||
from1To2: from1To2,
|
||||
from2To3: from2To3,
|
||||
from3To4: from3To4,
|
||||
from4To5: from4To5,
|
||||
from5To6: from5To6,
|
||||
));
|
||||
|
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
@ -1,12 +1,25 @@
|
||||
// import 'package:drift/drift.dart' hide Column;
|
||||
import 'package:flutter/material.dart';
|
||||
import 'package:provider/provider.dart';
|
||||
import 'package:sendtrain/daos/sessions_dao.dart';
|
||||
import 'package:sendtrain/database/database.dart';
|
||||
import '../widgets/session_card.dart';
|
||||
import 'package:collection/collection.dart';
|
||||
|
||||
class SessionsScreen extends StatelessWidget {
|
||||
const SessionsScreen({super.key});
|
||||
|
||||
Widget getSessionCard(session) {
|
||||
if (session != null) {
|
||||
return SessionCard(session: session);
|
||||
} else {
|
||||
return Padding(
|
||||
padding: EdgeInsets.all(15),
|
||||
child: Icon(Icons.do_not_disturb_alt_outlined)
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
return FutureBuilder<List<Session>>(
|
||||
@ -17,15 +30,15 @@ class SessionsScreen extends StatelessWidget {
|
||||
final pending = sessions.where((session) =>
|
||||
session.status == SessionStatus.completed ||
|
||||
session.status == SessionStatus.missed);
|
||||
final upcoming = sessions.firstWhere(
|
||||
final upcoming = sessions.firstWhereOrNull(
|
||||
(session) => session.status == SessionStatus.pending);
|
||||
final current = sessions.firstWhere(
|
||||
final current = sessions.firstWhereOrNull(
|
||||
(session) => session.status == SessionStatus.started);
|
||||
|
||||
List<Widget> previousSessions = List.generate(pending.length,
|
||||
(i) => SessionCard(type: 1, session: pending.elementAt(i)));
|
||||
Widget upcomingSession = SessionCard(session: upcoming);
|
||||
Widget currentSession = SessionCard(session: current);
|
||||
Widget upcomingSession = getSessionCard(upcoming);
|
||||
Widget currentSession = getSessionCard(current);
|
||||
|
||||
return Column(
|
||||
crossAxisAlignment: CrossAxisAlignment.start,
|
||||
|
@ -1,5 +1,6 @@
|
||||
import 'package:flutter/material.dart';
|
||||
import 'package:provider/provider.dart';
|
||||
import 'package:sendtrain/daos/activities_dao.dart';
|
||||
import 'package:sendtrain/daos/media_items_dao.dart';
|
||||
import 'package:sendtrain/database/database.dart';
|
||||
import 'package:sendtrain/extensions/string_extensions.dart';
|
||||
@ -56,7 +57,8 @@ class ActivityCardState extends State<ActivityCard> {
|
||||
return SlideTransition(
|
||||
position: custom,
|
||||
child: Dialog.fullscreen(
|
||||
child: ActivityView(activity: widget.activity)));
|
||||
child:
|
||||
ActivityView(activity: widget.activity)));
|
||||
},
|
||||
barrierDismissible: true,
|
||||
barrierLabel: '',
|
||||
@ -91,37 +93,91 @@ class ActivityCardState extends State<ActivityCard> {
|
||||
maxLines: 1,
|
||||
"${widget.activity.title.toTitleCase()} (${formattedTime(atm.totalTime)})");
|
||||
} else {
|
||||
return Text(maxLines: 1, widget.activity.title.toTitleCase());
|
||||
return Text(
|
||||
maxLines: 1,
|
||||
widget.activity.title.toTitleCase());
|
||||
}
|
||||
},
|
||||
),
|
||||
subtitle: Text(maxLines: 2, widget.activity.description),
|
||||
trailing: IconButton(
|
||||
visualDensity: VisualDensity.compact,
|
||||
icon: Icon(Icons.close_rounded),
|
||||
onPressed: () {
|
||||
showAdaptiveDialog(
|
||||
context: context,
|
||||
builder: (BuildContext context) => AlertDialog(
|
||||
title: const Text('Activity Removal'),
|
||||
content: const Text(
|
||||
'Would you like to permanently remove this activity from the current session?'),
|
||||
actions: <Widget>[
|
||||
TextButton(
|
||||
onPressed: () =>
|
||||
Navigator.pop(context, 'Cancel'),
|
||||
child: const Text('Cancel'),
|
||||
),
|
||||
TextButton(
|
||||
onPressed: () =>
|
||||
Navigator.pop(context, 'OK'),
|
||||
child: const Text('OK'),
|
||||
),
|
||||
],
|
||||
),
|
||||
);
|
||||
},
|
||||
)),
|
||||
subtitle:
|
||||
Text(maxLines: 2, widget.activity.description),
|
||||
contentPadding: EdgeInsets.only(left: 13),
|
||||
trailing: Flex(
|
||||
direction: Axis.vertical,
|
||||
mainAxisSize: MainAxisSize.max,
|
||||
children: [
|
||||
IconButton(
|
||||
padding: EdgeInsets.all(0),
|
||||
alignment: Alignment.topCenter,
|
||||
visualDensity: VisualDensity.compact,
|
||||
icon: Icon(Icons.close_rounded),
|
||||
onPressed: () {
|
||||
showAdaptiveDialog(
|
||||
context: context,
|
||||
builder: (BuildContext context) =>
|
||||
AlertDialog(
|
||||
title: const Text('Activity Removal'),
|
||||
content: const Text(
|
||||
'Would you like to permanently remove this activity from the current session?'),
|
||||
actions: <Widget>[
|
||||
TextButton(
|
||||
onPressed: () => Navigator.pop(
|
||||
context, 'Cancel'),
|
||||
child: const Text('Cancel'),
|
||||
),
|
||||
TextButton(
|
||||
onPressed: () => {
|
||||
ActivitiesDao(
|
||||
Provider.of<AppDatabase>(
|
||||
context,
|
||||
listen: false))
|
||||
.remove(widget.activity)
|
||||
.then((result) {
|
||||
setState(() {});
|
||||
}),
|
||||
Navigator.pop(context, 'OK')
|
||||
},
|
||||
child: const Text('OK'),
|
||||
),
|
||||
],
|
||||
),
|
||||
);
|
||||
},
|
||||
)
|
||||
])
|
||||
// trailing: FittedBox(
|
||||
// alignment: Alignment.topCenter,
|
||||
// fit: BoxFit.fitHeight,
|
||||
// child: IconButton(
|
||||
// padding: EdgeInsets.all(0),
|
||||
// alignment: Alignment.topCenter,
|
||||
// // visualDensity: VisualDensity.compact,
|
||||
// icon: Icon(Icons.close_rounded),
|
||||
// onPressed: () {
|
||||
// showAdaptiveDialog(
|
||||
// context: context,
|
||||
// builder: (BuildContext context) =>
|
||||
// AlertDialog(
|
||||
// title: const Text('Activity Removal'),
|
||||
// content: const Text(
|
||||
// 'Would you like to permanently remove this activity from the current session?'),
|
||||
// actions: <Widget>[
|
||||
// TextButton(
|
||||
// onPressed: () =>
|
||||
// Navigator.pop(context, 'Cancel'),
|
||||
// child: const Text('Cancel'),
|
||||
// ),
|
||||
// TextButton(
|
||||
// onPressed: () =>
|
||||
// Navigator.pop(context, 'OK'),
|
||||
// child: const Text('OK'),
|
||||
// ),
|
||||
// ],
|
||||
// ),
|
||||
// );
|
||||
// },
|
||||
// ))
|
||||
),
|
||||
],
|
||||
)),
|
||||
);
|
||||
|
@ -44,6 +44,16 @@ class _ActivityViewState extends State<ActivityView> {
|
||||
blur: 10,
|
||||
),
|
||||
children: [
|
||||
FloatingActionButton.extended(
|
||||
icon: const Icon(Icons.upload_outlined),
|
||||
label: Text('Upload Media'),
|
||||
onPressed: () {},
|
||||
),
|
||||
FloatingActionButton.extended(
|
||||
icon: const Icon(Icons.note_add_outlined),
|
||||
label: Text('Add Note'),
|
||||
onPressed: () {},
|
||||
),
|
||||
FloatingActionButton.extended(
|
||||
icon: const Icon(Icons.history_outlined),
|
||||
label: Text('Restart'),
|
||||
@ -54,11 +64,6 @@ class _ActivityViewState extends State<ActivityView> {
|
||||
label: Text('Done'),
|
||||
onPressed: () {},
|
||||
),
|
||||
FloatingActionButton.extended(
|
||||
icon: const Icon(Icons.edit_outlined),
|
||||
label: Text('Edit'),
|
||||
onPressed: () {},
|
||||
),
|
||||
]),
|
||||
body: Column(
|
||||
crossAxisAlignment: CrossAxisAlignment.start,
|
||||
|
@ -1,6 +1,9 @@
|
||||
import 'package:flutter/material.dart';
|
||||
import 'package:intl/intl.dart';
|
||||
import 'package:intl/date_symbol_data_local.dart';
|
||||
import 'package:provider/provider.dart';
|
||||
import 'package:sendtrain/daos/media_items_dao.dart';
|
||||
import 'package:sendtrain/daos/sessions_dao.dart';
|
||||
import 'package:sendtrain/database/database.dart' hide ActivityAction;
|
||||
import 'package:sendtrain/extensions/string_extensions.dart';
|
||||
import 'package:sendtrain/widgets/session_view.dart';
|
||||
@ -19,146 +22,193 @@ class SessionCard extends StatelessWidget {
|
||||
? Theme.of(context).colorScheme.primaryContainer
|
||||
: Theme.of(context).colorScheme.surfaceContainerLow;
|
||||
|
||||
if (type == 0) {
|
||||
return Card(
|
||||
color: color,
|
||||
margin: const EdgeInsets.fromLTRB(15, 15, 15, 0),
|
||||
clipBehavior: Clip.hardEdge,
|
||||
child: InkWell(
|
||||
splashColor: Colors.deepPurple,
|
||||
onTap: () => showGeneralDialog(
|
||||
barrierColor: Colors.black.withOpacity(0.5),
|
||||
transitionDuration: const Duration(milliseconds: 220),
|
||||
transitionBuilder: (BuildContext context,
|
||||
Animation<double> animation,
|
||||
Animation<double> secondaryAnimation,
|
||||
Widget child) {
|
||||
Animation<Offset> custom = Tween<Offset>(
|
||||
begin: const Offset(0.0, 1.0),
|
||||
end: const Offset(0.0, 0.0))
|
||||
.animate(animation);
|
||||
return SlideTransition(
|
||||
position: custom,
|
||||
child: Dialog.fullscreen(child: SessionView(session: session)));
|
||||
},
|
||||
barrierDismissible: true,
|
||||
barrierLabel: '',
|
||||
context: context,
|
||||
pageBuilder: (context, animation1, animation2) {
|
||||
return Container();
|
||||
}),
|
||||
child: Column(
|
||||
mainAxisSize: MainAxisSize.min,
|
||||
children: <Widget>[
|
||||
ListTile(
|
||||
leading: Padding(
|
||||
padding: const EdgeInsets.fromLTRB(0, 8, 0, 0),
|
||||
child: Container(
|
||||
width: 60,
|
||||
decoration: const BoxDecoration(
|
||||
image: DecorationImage(
|
||||
fit: BoxFit.cover,
|
||||
image:
|
||||
AssetImage('assets/images/placeholder.jpg')),
|
||||
// color: Colors.blue,
|
||||
borderRadius:
|
||||
BorderRadius.all(Radius.elliptical(10, 10)),
|
||||
),
|
||||
)),
|
||||
title: Text(maxLines: 1, session.title.toTitleCase()),
|
||||
subtitle: Text(maxLines: 1, dateFormat.format(session.date as DateTime)),
|
||||
trailing: IconButton(
|
||||
visualDensity: VisualDensity.compact,
|
||||
icon: Icon(Icons.close_rounded),
|
||||
onPressed: () {
|
||||
showAdaptiveDialog(
|
||||
return FutureBuilder<List<MediaItem>>(
|
||||
future: MediaItemsDao(Provider.of<AppDatabase>(context))
|
||||
.fromSession(session),
|
||||
builder: (context, snapshot) {
|
||||
if (snapshot.hasData) {
|
||||
List<MediaItem> mediaItems = snapshot.data!;
|
||||
|
||||
if (type == 0) {
|
||||
return Card(
|
||||
color: color,
|
||||
margin: const EdgeInsets.fromLTRB(15, 15, 15, 0),
|
||||
clipBehavior: Clip.hardEdge,
|
||||
child: InkWell(
|
||||
splashColor: Colors.deepPurple,
|
||||
onTap: () => showGeneralDialog(
|
||||
barrierColor: Colors.black.withOpacity(0.5),
|
||||
transitionDuration: const Duration(milliseconds: 220),
|
||||
transitionBuilder: (BuildContext context,
|
||||
Animation<double> animation,
|
||||
Animation<double> secondaryAnimation,
|
||||
Widget child) {
|
||||
Animation<Offset> custom = Tween<Offset>(
|
||||
begin: const Offset(0.0, 1.0),
|
||||
end: const Offset(0.0, 0.0))
|
||||
.animate(animation);
|
||||
return SlideTransition(
|
||||
position: custom,
|
||||
child: Dialog.fullscreen(
|
||||
child: SessionView(session: session)));
|
||||
},
|
||||
barrierDismissible: true,
|
||||
barrierLabel: '',
|
||||
context: context,
|
||||
builder: (BuildContext context) => AlertDialog(
|
||||
title: const Text('Session Removal'),
|
||||
content: const Text(
|
||||
'Would you like to permanently remove this session?'),
|
||||
actions: <Widget>[
|
||||
TextButton(
|
||||
onPressed: () => Navigator.pop(context, 'Cancel'),
|
||||
child: const Text('Cancel'),
|
||||
),
|
||||
TextButton(
|
||||
onPressed: () => Navigator.pop(context, 'OK'),
|
||||
child: const Text('OK'),
|
||||
),
|
||||
],
|
||||
pageBuilder: (context, animation1, animation2) {
|
||||
return Container();
|
||||
}),
|
||||
child: Column(
|
||||
mainAxisSize: MainAxisSize.min,
|
||||
children: <Widget>[
|
||||
ListTile(
|
||||
contentPadding: EdgeInsets.only(left: 15),
|
||||
leading: Padding(
|
||||
padding: const EdgeInsets.fromLTRB(0, 8, 0, 0),
|
||||
child: Container(
|
||||
width: 60,
|
||||
decoration: BoxDecoration(
|
||||
image: DecorationImage(
|
||||
fit: BoxFit.cover,
|
||||
image:
|
||||
findMediaByType(mediaItems, 'image')),
|
||||
// color: Colors.blue,
|
||||
borderRadius: BorderRadius.all(
|
||||
Radius.elliptical(10, 10)),
|
||||
),
|
||||
)),
|
||||
title: Text(maxLines: 1, session.title.toTitleCase()),
|
||||
subtitle: Text(
|
||||
maxLines: 1,
|
||||
dateFormat.format(session.date as DateTime)),
|
||||
trailing: IconButton(
|
||||
padding: EdgeInsets.all(0),
|
||||
alignment: Alignment.topCenter,
|
||||
icon: Icon(Icons.close_rounded),
|
||||
onPressed: () {
|
||||
showAdaptiveDialog(
|
||||
context: context,
|
||||
builder: (BuildContext context) => AlertDialog(
|
||||
title: const Text('Session Removal'),
|
||||
content: const Text(
|
||||
'Would you like to permanently remove this session?'),
|
||||
actions: <Widget>[
|
||||
TextButton(
|
||||
onPressed: () => {
|
||||
Navigator.pop(context, 'Cancel'),
|
||||
},
|
||||
child: const Text('Cancel'),
|
||||
),
|
||||
TextButton(
|
||||
onPressed: () => {
|
||||
SessionsDao(Provider.of<AppDatabase>(
|
||||
context, listen: false))
|
||||
.remove(session).then((result) {
|
||||
// ignore: invalid_use_of_protected_member
|
||||
(context as Element).reassemble();
|
||||
}),
|
||||
Navigator.pop(context, 'OK')
|
||||
},
|
||||
child: const Text('OK'),
|
||||
),
|
||||
],
|
||||
),
|
||||
);
|
||||
},
|
||||
),
|
||||
),
|
||||
);
|
||||
},
|
||||
),
|
||||
),
|
||||
ListTile(
|
||||
contentPadding: const EdgeInsets.fromLTRB(15, 0, 15, 15),
|
||||
title: Text(
|
||||
maxLines: 2,
|
||||
overflow: TextOverflow.ellipsis,
|
||||
style: const TextStyle(fontWeight: FontWeight.w300),
|
||||
session.content),
|
||||
),
|
||||
],
|
||||
)),
|
||||
);
|
||||
ListTile(
|
||||
contentPadding:
|
||||
const EdgeInsets.fromLTRB(15, 0, 15, 15),
|
||||
title: Text(
|
||||
maxLines: 2,
|
||||
overflow: TextOverflow.ellipsis,
|
||||
style:
|
||||
const TextStyle(fontWeight: FontWeight.w300),
|
||||
session.content),
|
||||
),
|
||||
],
|
||||
)),
|
||||
);
|
||||
} else {
|
||||
return Card(
|
||||
color: color,
|
||||
child: InkWell(
|
||||
// overlayColor: MaterialStateColor(Colors.deepPurple as int),
|
||||
splashColor: Colors.deepPurple,
|
||||
borderRadius:
|
||||
const BorderRadius.all(Radius.elliptical(10, 10)),
|
||||
onTap: () => showGeneralDialog(
|
||||
// barrierColor: Colors.black.withOpacity(0.5),
|
||||
transitionDuration: const Duration(milliseconds: 220),
|
||||
transitionBuilder: (BuildContext context,
|
||||
Animation<double> animation,
|
||||
Animation<double> secondaryAnimation,
|
||||
Widget child) {
|
||||
Animation<Offset> custom = Tween<Offset>(
|
||||
begin: const Offset(0.0, 1.0),
|
||||
end: const Offset(0.0, 0.0))
|
||||
.animate(animation);
|
||||
return SlideTransition(
|
||||
position: custom,
|
||||
child: Dialog.fullscreen(
|
||||
child: SessionView(session: session)));
|
||||
},
|
||||
barrierDismissible: true,
|
||||
barrierLabel: '',
|
||||
context: context,
|
||||
pageBuilder: (context, animation1, animation2) {
|
||||
return Container();
|
||||
}),
|
||||
child: Container(
|
||||
decoration: BoxDecoration(
|
||||
// color: const Color.fromARGB(47, 0, 0, 0),
|
||||
borderRadius: BorderRadius.circular(10),
|
||||
image: DecorationImage(
|
||||
colorFilter: ColorFilter.mode(
|
||||
Color.fromARGB(220, 41, 39, 39),
|
||||
BlendMode.hardLight),
|
||||
image: findMediaByType(mediaItems, 'image'),
|
||||
fit: BoxFit.cover),
|
||||
),
|
||||
child: Align(
|
||||
alignment: Alignment.center,
|
||||
child: Column(
|
||||
mainAxisSize: MainAxisSize.min,
|
||||
children: <Widget>[
|
||||
ListTile(
|
||||
title: Text(
|
||||
maxLines: 3,
|
||||
session.title.toTitleCase(),
|
||||
textAlign: TextAlign.center),
|
||||
subtitle: Text(
|
||||
maxLines: 1,
|
||||
dateFormat
|
||||
.format(session.date as DateTime),
|
||||
textAlign: TextAlign.center),
|
||||
),
|
||||
])))));
|
||||
}
|
||||
} else {
|
||||
return Container(
|
||||
alignment: Alignment.center,
|
||||
child: SizedBox(
|
||||
height: 50.0,
|
||||
width: 50.0,
|
||||
child: CircularProgressIndicator(),
|
||||
));
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
ImageProvider findMediaByType(List<MediaItem> media, String type) {
|
||||
Iterable<MediaItem>? found = media.where((m) => m.type == MediaType.image);
|
||||
|
||||
if (found.isNotEmpty) {
|
||||
return NetworkImage(found.first.reference);
|
||||
} else {
|
||||
return Card(
|
||||
color: color,
|
||||
child: InkWell(
|
||||
// overlayColor: MaterialStateColor(Colors.deepPurple as int),
|
||||
splashColor: Colors.deepPurple,
|
||||
borderRadius: const BorderRadius.all(Radius.elliptical(10, 10)),
|
||||
onTap: () => showGeneralDialog(
|
||||
// barrierColor: Colors.black.withOpacity(0.5),
|
||||
transitionDuration: const Duration(milliseconds: 220),
|
||||
transitionBuilder: (BuildContext context,
|
||||
Animation<double> animation,
|
||||
Animation<double> secondaryAnimation,
|
||||
Widget child) {
|
||||
Animation<Offset> custom = Tween<Offset>(
|
||||
begin: const Offset(0.0, 1.0),
|
||||
end: const Offset(0.0, 0.0))
|
||||
.animate(animation);
|
||||
return SlideTransition(
|
||||
position: custom,
|
||||
child:
|
||||
Dialog.fullscreen(child: SessionView(session: session)));
|
||||
},
|
||||
barrierDismissible: true,
|
||||
barrierLabel: '',
|
||||
context: context,
|
||||
pageBuilder: (context, animation1, animation2) {
|
||||
return Container();
|
||||
}),
|
||||
child: Container(
|
||||
decoration: BoxDecoration(
|
||||
// color: const Color.fromARGB(47, 0, 0, 0),
|
||||
borderRadius: BorderRadius.circular(10),
|
||||
image: const DecorationImage(
|
||||
colorFilter: ColorFilter.mode(
|
||||
Color.fromARGB(220, 41, 39, 39),
|
||||
BlendMode.hardLight),
|
||||
image: AssetImage('assets/images/placeholder.jpg'),
|
||||
fit: BoxFit.cover),
|
||||
),
|
||||
child: Align(
|
||||
alignment: Alignment.center,
|
||||
child: Column(
|
||||
mainAxisSize: MainAxisSize.min,
|
||||
children: <Widget>[
|
||||
ListTile(
|
||||
title: Text(
|
||||
maxLines: 3,
|
||||
session.title.toTitleCase(),
|
||||
textAlign: TextAlign.center),
|
||||
subtitle: Text(
|
||||
maxLines: 1,
|
||||
dateFormat.format(session.date as DateTime),
|
||||
textAlign: TextAlign.center),
|
||||
),
|
||||
])))));
|
||||
// Element is not found
|
||||
return const AssetImage('assets/images/placeholder.jpg');
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -4,6 +4,7 @@ import 'package:intl/intl.dart';
|
||||
import 'package:intl/date_symbol_data_local.dart';
|
||||
import 'package:provider/provider.dart';
|
||||
import 'package:sendtrain/daos/activities_dao.dart';
|
||||
import 'package:sendtrain/daos/sessions_dao.dart';
|
||||
|
||||
import 'package:sendtrain/database/database.dart';
|
||||
import 'package:sendtrain/extensions/string_extensions.dart';
|
||||
|
@ -7,6 +7,8 @@ import 'schema_v1.dart' as v1;
|
||||
import 'schema_v2.dart' as v2;
|
||||
import 'schema_v3.dart' as v3;
|
||||
import 'schema_v4.dart' as v4;
|
||||
import 'schema_v5.dart' as v5;
|
||||
import 'schema_v6.dart' as v6;
|
||||
|
||||
class GeneratedHelper implements SchemaInstantiationHelper {
|
||||
@override
|
||||
@ -20,10 +22,14 @@ class GeneratedHelper implements SchemaInstantiationHelper {
|
||||
return v3.DatabaseAtV3(db);
|
||||
case 4:
|
||||
return v4.DatabaseAtV4(db);
|
||||
case 5:
|
||||
return v5.DatabaseAtV5(db);
|
||||
case 6:
|
||||
return v6.DatabaseAtV6(db);
|
||||
default:
|
||||
throw MissingSchemaException(version, versions);
|
||||
}
|
||||
}
|
||||
|
||||
static const versions = const [1, 2, 3, 4];
|
||||
static const versions = const [1, 2, 3, 4, 5, 6];
|
||||
}
|
||||
|
2012
test/drift/sendtrain/generated/schema_v5.dart
Normal file
2012
test/drift/sendtrain/generated/schema_v5.dart
Normal file
File diff suppressed because it is too large
Load Diff
2012
test/drift/sendtrain/generated/schema_v6.dart
Normal file
2012
test/drift/sendtrain/generated/schema_v6.dart
Normal file
File diff suppressed because it is too large
Load Diff
Loading…
x
Reference in New Issue
Block a user