Skip to content

Commit

Permalink
rename: v2
Browse files Browse the repository at this point in the history
  • Loading branch information
zin- committed Sep 18, 2024
1 parent 730da61 commit 758318b
Show file tree
Hide file tree
Showing 14 changed files with 112 additions and 94 deletions.
4 changes: 1 addition & 3 deletions lib/acts/act_service.dart
Original file line number Diff line number Diff line change
Expand Up @@ -27,9 +27,7 @@ class ActService {
actOrderBy: ActOrderBy.descStart,
offset: offset,
limit: limit,
))
// .map((e) => e.toV1())
.toList(),
)),
await _actRepository.count(memId: memId),
),
{
Expand Down
4 changes: 2 additions & 2 deletions lib/components/date_and_time/date_and_time_period_view.dart
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,7 @@ class DateAndTimePeriodTextFormFields extends StatelessWidget {
direction: Axis.vertical,
mainAxisSize: MainAxisSize.min,
children: [
DateAndTimeTextFormFieldV2(
DateAndTimeTextFormField(
_dateAndTimePeriod?.start,
(pickedDateAndTime) => v(
() =>
Expand All @@ -76,7 +76,7 @@ class DateAndTimePeriodTextFormFields extends StatelessWidget {
end: _dateAndTimePeriod?.end,
),
),
DateAndTimeTextFormFieldV2(
DateAndTimeTextFormField(
_dateAndTimePeriod?.end,
(pickedDateAndTime) => v(
() => _dateAndTimePeriod?.start == null &&
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,12 +5,12 @@ 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/logger/log_service.dart';

class DateAndTimeTextFormFieldV2 extends StatelessWidget {
class DateAndTimeTextFormField extends StatelessWidget {
final DateAndTime? _dateAndTime;
final void Function(DateAndTime? pickedDateAndTime) _onChanged;
final DateAndTimePeriod? _selectableRange;

const DateAndTimeTextFormFieldV2(
const DateAndTimeTextFormField(
this._dateAndTime,
this._onChanged, {
super.key,
Expand Down
12 changes: 5 additions & 7 deletions lib/components/mem/list/states.dart
Original file line number Diff line number Diff line change
Expand Up @@ -253,11 +253,9 @@ final savedMemNotificationsProvider = StateNotifierProvider.autoDispose<

final activeActsProvider = StateNotifierProvider.autoDispose<
ListValueStateNotifier<SavedActEntity>, List<SavedActEntity>>(
(ref) => v(() => ListValueStateNotifier(
ref
.watch(actsProvider)
// .map((e) => e.toV1())
.where((act) => act.isActive)
.toList(),
)),
(ref) => v(
() => ListValueStateNotifier(
ref.watch(actsProvider).where((act) => act.isActive).toList(),
),
),
);
4 changes: 2 additions & 2 deletions lib/core/mem_item.dart
Original file line number Diff line number Diff line change
Expand Up @@ -2,10 +2,10 @@ enum MemItemType {
memo,
}

class MemItemV2 {
class MemItem {
final int? memId;
final MemItemType type;
final dynamic value;

MemItemV2(this.memId, this.type, this.value);
MemItem(this.memId, this.type, this.value);
}
4 changes: 2 additions & 2 deletions lib/notifications/notification/notification.dart
Original file line number Diff line number Diff line change
Expand Up @@ -2,13 +2,13 @@ import 'package:mem/framework/repository/entity.dart';
import 'package:mem/framework/repository/key_with_value.dart';
import 'package:mem/notifications/notification/channel.dart';

class NotificationV2 with Entity, KeyWithValue<int, Map<String, dynamic>> {
class Notification with Entity, KeyWithValue<int, Map<String, dynamic>> {
final String title;
final String body;
final NotificationChannel channel;
final Map<String, dynamic> payload;

NotificationV2(
Notification(
int id,
this.title,
this.body,
Expand Down
4 changes: 2 additions & 2 deletions lib/notifications/notification_channels.dart
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ class NotificationChannels {

late final Map<String, NotificationAction> actionMap;

Future<NotificationV2> buildNotification(
Future<Notification> buildNotification(
NotificationType notificationType,
int memId,
) =>
Expand Down Expand Up @@ -52,7 +52,7 @@ class NotificationChannels {
break;
}

return NotificationV2(
return Notification(
notificationType.buildNotificationId(memId),
title,
body,
Expand Down
4 changes: 2 additions & 2 deletions lib/notifications/notification_repository.dart
Original file line number Diff line number Diff line change
Expand Up @@ -9,15 +9,15 @@ import 'package:mem/values/paths.dart';
import 'notification/notification.dart';
import 'flutter_local_notifications_wrapper.dart';

class NotificationRepository extends KeyWithValueRepository<NotificationV2, int>
class NotificationRepository extends KeyWithValueRepository<Notification, int>
with DiscardAll {
final FlutterLocalNotificationsWrapper? _flutterLocalNotificationsWrapper =
defaultTargetPlatform == TargetPlatform.android
? FlutterLocalNotificationsWrapper(androidDefaultIconPath)
: null;

@override
Future<void> receive(NotificationV2 entity) => v(
Future<void> receive(Notification entity) => v(
() async {
if (await PermissionHandlerWrapper().grant(Permission.notification)) {
await _flutterLocalNotificationsWrapper?.show(
Expand Down
2 changes: 1 addition & 1 deletion lib/repositories/mem_item_entity.dart
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ import 'package:mem/databases/table_definitions/mem_items.dart';
import 'package:mem/framework/repository/database_tuple_entity.dart';
import 'package:mem/framework/repository/entity.dart';

class MemItemEntity extends MemItemV2 with Entity, Copyable<MemItemEntity> {
class MemItemEntity extends MemItem with Entity, Copyable<MemItemEntity> {
MemItemEntity(super.memId, super.type, super.value);

MemItemEntity.fromMap(Map<String, dynamic> map)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,14 +12,14 @@ void main() {

for (final testCase in [
TestCase(
'pick start',
name: 'pick start',
DateAndTimePeriod(start: DateAndTime.from(now)),
(input) => null,
null,
),
TestCase(
'pick end',
name: 'pick end',
DateAndTimePeriod(end: DateAndTime.from(now)),
(input) => null,
null,
),
]) {
testWidgets(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ void main() {
}) async {
await widgetTester.pumpWidget(MaterialApp(
home: Scaffold(
body: DateAndTimeTextFormFieldV2(
body: DateAndTimeTextFormField(
dateAndTime,
onChanged,
selectableRange: selectableRange,
Expand Down
8 changes: 4 additions & 4 deletions test/core/date_and_time_period_test.dart
Original file line number Diff line number Diff line change
Expand Up @@ -266,7 +266,7 @@ void main() {

group(": compare", () {
for (var testCase in [
TestCaseV2(
TestCase(
name: "both are not null",
[
DateAndTimePeriod.startNow(),
Expand All @@ -275,17 +275,17 @@ void main() {
DateAndTimePeriod.startNow()
.compareTo(DateAndTimePeriod(end: DateAndTime.now())),
),
TestCaseV2(
TestCase(
name: "both are null",
[null, null],
0,
),
TestCaseV2(
TestCase(
name: "a is null, b is not null",
[null, DateAndTimePeriod.startNow()],
1,
),
TestCaseV2(
TestCase(
name: "a is not null, b is null",
[DateAndTimePeriod.startNow(), null],
-1,
Expand Down
16 changes: 4 additions & 12 deletions test/helpers.dart
Original file line number Diff line number Diff line change
Expand Up @@ -44,20 +44,12 @@ Widget buildTestAppWithProvider(
child: buildTestApp(widget),
);

class TestCaseV2<I> {
final I input;
final dynamic expected;
class TestCase<INPUT, EXPECTED> {
final INPUT input;
final EXPECTED expected;
final String? name;

TestCaseV2(this.input, this.expected, {this.name});
}

class TestCase<T> {
final String name;
final T input;
final Function(T input) verify;

TestCase(this.name, this.input, this.verify);
TestCase(this.input, this.expected, {this.name});
}

// Finders
Expand Down
Loading

0 comments on commit 758318b

Please sign in to comment.