Skip to content

Commit

Permalink
drop: Mem v1
Browse files Browse the repository at this point in the history
drop: EntityV1
  • Loading branch information
zin- committed Sep 18, 2024
1 parent 645553e commit 730da61
Show file tree
Hide file tree
Showing 33 changed files with 633 additions and 781 deletions.
885 changes: 420 additions & 465 deletions integration_test/scenarios/habit/repeat_by_n_day_habit_scenario.dart

Large diffs are not rendered by default.

8 changes: 5 additions & 3 deletions lib/act_counter/act_counter.dart
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ import 'package:mem/act_counter/home_widget.dart';
import 'package:mem/core/date_and_time/date_and_time.dart';
import 'package:mem/core/date_and_time/date_and_time_period.dart';
import 'package:mem/repositories/act_entity.dart';
import 'package:mem/repositories/mem.dart';
import 'package:mem/repositories/mem_entity.dart';

class ActCounter implements HomeWidget {
@override
Expand All @@ -23,8 +23,10 @@ class ActCounter implements HomeWidget {

ActCounter(this.memId, this.name, this.actCount, this.updatedAt);

ActCounter.from(SavedMemV1 savedMem, Iterable<SavedActEntity> savedActs)
: memId = savedMem.id,
ActCounter.from(
SavedMemEntity savedMem,
Iterable<SavedActEntity> savedActs,
) : memId = savedMem.id,
name = savedMem.name,
actCount = savedActs.length,
updatedAt = savedActs
Expand Down
4 changes: 2 additions & 2 deletions lib/act_counter/act_counter_client.dart
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ class ActCounterClient {
() async {
await _actCounterRepository.receive(
ActCounterEntity.from(
await _memRepository.ship(id: memId).then((v) => v.single.toV1()),
await _memRepository.ship(id: memId).then((v) => v.single),
await _actRepository.ship(
memId: memId,
period: ActCounter.period(DateAndTime.now()),
Expand All @@ -44,7 +44,7 @@ class ActCounterClient {

await _actCounterRepository.replace(
ActCounterEntity.from(
await _memRepository.ship(id: memId).then((v) => v.single.toV1()),
await _memRepository.ship(id: memId).then((v) => v.single),
await _actRepository.ship(
memId: memId,
period: ActCounter.period(when),
Expand Down
4 changes: 2 additions & 2 deletions lib/act_counter/single_selectable_mem_list_item.dart
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ import 'package:mem/components/mem/list/states.dart';
import 'package:mem/components/mem/mem_name.dart';
import 'package:mem/components/mem/mem_period.dart';
import 'package:mem/logger/log_service.dart';
import 'package:mem/repositories/mem.dart';
import 'package:mem/repositories/mem_entity.dart';

import 'states.dart';

Expand All @@ -31,7 +31,7 @@ class SingleSelectableMemListItem extends ConsumerWidget {

class _SingleSelectableMemListItemComponent extends ListTile {
_SingleSelectableMemListItemComponent(
SavedMemV1 mem,
SavedMemEntity mem,
bool isSelected,
void Function(int? memId) onSelected,
) : super(
Expand Down
11 changes: 7 additions & 4 deletions lib/acts/list/act_list.dart
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ import 'package:mem/acts/states.dart';
import 'package:mem/components/mem/list/states.dart';
import 'package:mem/core/act.dart';
import 'package:mem/logger/log_service.dart';
import 'package:mem/repositories/mem.dart';
import 'package:mem/repositories/mem_entity.dart';

import 'app_bar.dart';
import 'item/builder.dart';
Expand Down Expand Up @@ -66,7 +66,7 @@ class _ActList extends StatelessWidget {
final bool _isDateView;
final bool _isTimeView;
final List<Act> _actList;
final List<SavedMemV1> _memList;
final List<SavedMemEntity> _memList;
final ScrollController? _scrollController;

const _ActList(
Expand Down Expand Up @@ -100,8 +100,11 @@ class _ActList extends StatelessWidget {
header: ActListSubHeader(e, _isDateView),
sliver: SliverList(
delegate: () {
final builder =
ActListItemBuilder(e, _memList, _isTimeView);
final builder = ActListItemBuilder(
e,
_memList,
_isTimeView,
);

return SliverChildBuilderDelegate(
builder.build,
Expand Down
4 changes: 2 additions & 2 deletions lib/acts/list/item/builder.dart
Original file line number Diff line number Diff line change
Expand Up @@ -3,14 +3,14 @@ import 'package:flutter/material.dart';
import 'package:mem/core/act.dart';
import 'package:mem/logger/log_service.dart';
import 'package:mem/repositories/act_entity.dart';
import 'package:mem/repositories/mem.dart';
import 'package:mem/repositories/mem_entity.dart';

import 'total_act_time_item.dart';
import 'view.dart';

class ActListItemBuilder {
final MapEntry<DateTime, List<Act>> _actListWithDatetime;
final List<SavedMemV1> _memList;
final List<SavedMemEntity> _memList;
final bool _isTimeView;

late final Map _actListGroupedByMemId;
Expand Down
4 changes: 2 additions & 2 deletions lib/acts/list/item/total_act_time_item.dart
Original file line number Diff line number Diff line change
Expand Up @@ -3,11 +3,11 @@ import 'package:mem/core/act.dart';
import 'package:mem/core/date_and_time/duration.dart';
import 'package:mem/logger/log_service.dart';
import 'package:mem/mems/transitions.dart';
import 'package:mem/repositories/mem.dart';
import 'package:mem/repositories/mem_entity.dart';

class TotalActTimeListItem extends StatelessWidget {
final List<Act> _actList;
final SavedMemV1? _mem;
final SavedMemEntity? _mem;

const TotalActTimeListItem(this._actList, this._mem, {super.key});

Expand Down
6 changes: 3 additions & 3 deletions lib/components/created_and_updated_at_texts.dart
Original file line number Diff line number Diff line change
Expand Up @@ -3,18 +3,18 @@ import 'package:mem/components/date_and_time/date_and_time_view.dart';
import 'package:mem/core/date_and_time/date_and_time.dart';
import 'package:mem/core/mem.dart';
import 'package:mem/logger/log_service.dart';
import 'package:mem/repositories/mem.dart';
import 'package:mem/repositories/mem_entity.dart';
import 'package:mem/values/colors.dart';

class CreatedAndUpdatedAtTexts extends StatelessWidget {
final MemV1 _entity;
final Mem _entity;

const CreatedAndUpdatedAtTexts(this._entity, {super.key});

@override
Widget build(BuildContext context) => v(
() {
if (_entity is SavedMemV1) {
if (_entity is SavedMemEntity) {
return Wrap(
direction: Axis.horizontal,
children: [
Expand Down
14 changes: 6 additions & 8 deletions lib/components/mem/list/actions.dart
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ import 'package:flutter_riverpod/flutter_riverpod.dart';
import 'package:mem/components/mem/list/states.dart';
import 'package:mem/logger/log_service.dart';
import 'package:mem/mems/mem_item_repository.dart';
import 'package:mem/repositories/mem.dart';
import 'package:mem/repositories/mem_entity.dart';
import 'package:mem/repositories/mem_item_entity.dart';
import 'package:mem/repositories/mem_repository.dart';
import 'package:mem/mems/states.dart';
Expand All @@ -16,12 +16,10 @@ final loadMemList = FutureProvider(
final showDone = ref.watch(showDoneProvider);

final mems = await v(
() => MemRepository()
.ship(
archived: showNotArchived == showArchived ? null : showArchived,
done: showNotDone == showDone ? null : showDone,
)
.then((value) => value.map((e) => e.toV1())),
() => MemRepository().ship(
archived: showNotArchived == showArchived ? null : showArchived,
done: showNotDone == showDone ? null : showDone,
),
{
'showNotArchived': showNotArchived,
'showArchived': showArchived,
Expand All @@ -32,7 +30,7 @@ final loadMemList = FutureProvider(

ref.read(memsProvider.notifier).upsertAll(
mems,
(tmp, item) => tmp is SavedMemV1 && item is SavedMemV1
(tmp, item) => tmp is SavedMemEntity && item is SavedMemEntity
? tmp.id == item.id
: false,
);
Expand Down
32 changes: 17 additions & 15 deletions lib/components/mem/list/states.dart
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ import 'package:mem/mems/states.dart';
import 'package:mem/notifications/mem_notifications.dart';
import 'package:mem/repositories/act_entity.dart';
import 'package:mem/repositories/act_repository.dart';
import 'package:mem/repositories/mem.dart';
import 'package:mem/repositories/mem_entity.dart';
import 'package:mem/repositories/mem_notification_entity.dart';
import 'package:mem/repositories/mem_notification_repository.dart';
import 'package:mem/settings/states.dart';
Expand Down Expand Up @@ -40,9 +40,9 @@ final showDoneProvider = StateNotifierProvider<ValueStateNotifier<bool>, bool>(
),
);
final _filteredMemsProvider = StateNotifierProvider.autoDispose<
ListValueStateNotifier<SavedMemV1>, List<SavedMemV1>>(
ListValueStateNotifier<SavedMemEntity>, List<SavedMemEntity>>(
(ref) {
final savedMems = ref.watch(memsProvider).map((e) => e as SavedMemV1);
final savedMems = ref.watch(memsProvider).whereType<SavedMemEntity>();

final showNotArchived = ref.watch(showNotArchivedProvider);
final showArchived = ref.watch(showArchivedProvider);
Expand Down Expand Up @@ -86,7 +86,7 @@ final _filteredMemsProvider = StateNotifierProvider.autoDispose<
);

final memListProvider = StateNotifierProvider.autoDispose<
ValueStateNotifier<List<SavedMemV1>>, List<SavedMemV1>>((ref) {
ValueStateNotifier<List<SavedMemEntity>>, List<SavedMemEntity>>((ref) {
final filtered = ref.watch(_filteredMemsProvider);
final latestActsByMem = ref.watch(latestActsByMemProvider);
final savedMemNotifications = ref.watch(savedMemNotificationsProvider);
Expand Down Expand Up @@ -199,15 +199,15 @@ final latestActsByMemProvider = StateNotifierProvider.autoDispose<
initializer: (current, notifier) => v(
() async {
if (current.isEmpty) {
final memIds =
ref.read(memsProvider).whereType<SavedMemV1>().map((e) => e.id);

final actsByMemIds = await ActRepository().ship(
memIdsIn: memIds,
latestByMemIds: true,
);

ref.read(actsProvider.notifier).addAll(actsByMemIds);
ref.read(actsProvider.notifier).addAll(
await ActRepository().ship(
memIdsIn: ref
.read(memsProvider)
.whereType<SavedMemEntity>()
.map((e) => e.id),
latestByMemIds: true,
),
);
}
},
{'current': current},
Expand All @@ -227,8 +227,10 @@ final savedMemNotificationsProvider = StateNotifierProvider.autoDispose<
initializer: (current, notifier) => v(
() async {
if (current.isEmpty) {
final memIds =
ref.read(memsProvider).whereType<SavedMemV1>().map((e) => e.id);
final memIds = ref
.read(memsProvider)
.whereType<SavedMemEntity>()
.map((e) => e.id);

final actsByMemIds = await MemNotificationRepository().ship(
memIdsIn: memIds,
Expand Down
4 changes: 2 additions & 2 deletions lib/components/mem/list/view.dart
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ import 'package:flutter/material.dart';
import 'package:flutter_riverpod/flutter_riverpod.dart';
import 'package:mem/components/async_value_view.dart';
import 'package:mem/logger/log_service.dart';
import 'package:mem/repositories/mem.dart';
import 'package:mem/repositories/mem_entity.dart';

import 'actions.dart';
import 'states.dart';
Expand Down Expand Up @@ -32,7 +32,7 @@ class MemListView extends ConsumerWidget {
}

class _MemListViewComponent extends StatelessWidget {
final List<SavedMemV1> _memList;
final List<SavedMemEntity> _memList;
final Widget _appBar;
final Widget Function(int memId) _itemBuilder;
final ScrollController? _scrollController;
Expand Down
8 changes: 4 additions & 4 deletions lib/components/mem/mem_done_checkbox.dart
Original file line number Diff line number Diff line change
Expand Up @@ -2,10 +2,10 @@ import 'package:flutter/material.dart';
import 'package:mem/core/mem.dart';
import 'package:mem/components/hero_view.dart';
import 'package:mem/logger/log_service.dart';
import 'package:mem/repositories/mem.dart';
import 'package:mem/repositories/mem_entity.dart';

class MemDoneCheckbox extends StatelessWidget {
final MemV1 _mem;
final Mem _mem;
final Function(bool? value) _onChanged;

const MemDoneCheckbox(
Expand All @@ -19,11 +19,11 @@ class MemDoneCheckbox extends StatelessWidget {
() => HeroView(
heroTag(
'mem-done',
_mem is SavedMemV1 ? _mem.id : null,
_mem is SavedMemEntity ? _mem.id : null,
),
Checkbox(
value: _mem.isDone,
onChanged: (_mem is SavedMemV1 ? _mem.isArchived : false)
onChanged: (_mem is SavedMemEntity ? _mem.isArchived : false)
? null
: _onChanged,
),
Expand Down
4 changes: 2 additions & 2 deletions lib/components/mem/mem_name.dart
Original file line number Diff line number Diff line change
Expand Up @@ -4,14 +4,14 @@ import 'package:mem/components/hero_view.dart';
import 'package:mem/components/l10n.dart';
import 'package:mem/logger/log_service.dart';
import 'package:mem/mems/detail/states.dart';
import 'package:mem/repositories/mem.dart';
import 'package:mem/repositories/mem_entity.dart';

Key keyMemName = const Key("mem-name");

String _memNameTag(int? memId) => heroTag('mem-name', memId);

class MemNameText extends StatelessWidget {
final SavedMemV1 _mem;
final SavedMemEntity _mem;

const MemNameText(this._mem, {super.key});

Expand Down
Loading

0 comments on commit 730da61

Please sign in to comment.