Skip to content

Commit

Permalink
Fix week system in calendar week view
Browse files Browse the repository at this point in the history
  • Loading branch information
CodeDoctorDE committed May 13, 2024
1 parent ae24cfd commit b5542f8
Show file tree
Hide file tree
Showing 6 changed files with 20 additions and 25 deletions.
4 changes: 2 additions & 2 deletions api/pubspec.lock
Original file line number Diff line number Diff line change
Expand Up @@ -165,8 +165,8 @@ packages:
dependency: "direct main"
description:
path: "packages/dart_leap"
ref: "992f8062618ef1e78ee92efc7a709eb0d476e1d0"
resolved-ref: "992f8062618ef1e78ee92efc7a709eb0d476e1d0"
ref: f80aea0ab6cdc6df7c8e6ef54d6f3ed1efd1704d
resolved-ref: f80aea0ab6cdc6df7c8e6ef54d6f3ed1efd1704d
url: "https://github.com/LinwoodDev/dart_pkgs"
source: git
version: "1.0.0"
Expand Down
2 changes: 1 addition & 1 deletion api/pubspec.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ dependencies:
dart_leap:
git:
url: https://github.com/LinwoodDev/dart_pkgs
ref: 992f8062618ef1e78ee92efc7a709eb0d476e1d0
ref: f80aea0ab6cdc6df7c8e6ef54d6f3ed1efd1704d
path: packages/dart_leap
dev_dependencies:
build_runner: ^2.4.9
Expand Down
12 changes: 5 additions & 7 deletions app/lib/pages/calendar/week.dart
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ class CalendarWeekView extends StatefulWidget {

class _CalendarWeekViewState extends State<CalendarWeekView> {
late final FlowCubit _cubit;
int _week = 0, _year = 0, _startOfWeek = 0;
int _week = 0, _year = 0;
late Future<List<List<SourcedConnectedModel<CalendarItem, Event?>>>>
_appointments;
final _columnScrollController = ScrollController(),
Expand All @@ -44,13 +44,11 @@ class _CalendarWeekViewState extends State<CalendarWeekView> {
final now = DateTime.now();
_week = now.week;
_year = now.year;
_startOfWeek = context.read<SettingsCubit>().state.startOfWeek;
_appointments = _fetchCalendarItems();
}

DateTime get _date => DateTime(_year, 1, 1)
.nextStartOfWeek
.addDays((_week - 1) * 7 + _startOfWeek);
DateTime get _date =>
DateTime(_year, 1, 1).nextStartOfWeek.addDays((_week - 2) * 7);

Future<List<List<SourcedConnectedModel<CalendarItem, Event?>>>>
_fetchCalendarItems() async {
Expand Down Expand Up @@ -91,7 +89,7 @@ class _CalendarWeekViewState extends State<CalendarWeekView> {

void _addWeek(int add) {
setState(() {
final dateTime = DateTime(_year, 1, 1).addDays((_week + add) * 7);
final dateTime = _date.addDays(add * 7);
_week = dateTime.week;
_year = dateTime.year;
_appointments = _fetchCalendarItems();
Expand All @@ -112,7 +110,7 @@ class _CalendarWeekViewState extends State<CalendarWeekView> {

@override
Widget build(BuildContext context) {
final now = DateTime.now().addDays(-_startOfWeek);
final now = DateTime.now();

return LayoutBuilder(
builder: (context, constraints) => CreateEventScaffold(
Expand Down
19 changes: 9 additions & 10 deletions app/pubspec.lock
Original file line number Diff line number Diff line change
Expand Up @@ -213,8 +213,8 @@ packages:
dependency: transitive
description:
path: "packages/dart_leap"
ref: "992f8062618ef1e78ee92efc7a709eb0d476e1d0"
resolved-ref: "992f8062618ef1e78ee92efc7a709eb0d476e1d0"
ref: f80aea0ab6cdc6df7c8e6ef54d6f3ed1efd1704d
resolved-ref: f80aea0ab6cdc6df7c8e6ef54d6f3ed1efd1704d
url: "https://github.com/LinwoodDev/dart_pkgs"
source: git
version: "1.0.0"
Expand Down Expand Up @@ -642,8 +642,8 @@ packages:
dependency: "direct main"
description:
path: "packages/material_leap"
ref: "9338503df442df2e9a156511de1e93dfee8c4257"
resolved-ref: "9338503df442df2e9a156511de1e93dfee8c4257"
ref: "11a97be0a5bd85c14bdbb6555da8e84bbdd41ccb"
resolved-ref: "11a97be0a5bd85c14bdbb6555da8e84bbdd41ccb"
url: "https://github.com/LinwoodDev/dart_pkgs"
source: git
version: "0.0.1"
Expand Down Expand Up @@ -770,12 +770,11 @@ packages:
phosphor_flutter:
dependency: "direct main"
description:
path: "."
ref: f370dd2c25d3ea51ffb8f1c7c183bc9f33889c82
resolved-ref: f370dd2c25d3ea51ffb8f1c7c183bc9f33889c82
url: "https://github.com/CodeDoctorDE/phosphor-flutter"
source: git
version: "2.0.0"
name: phosphor_flutter
sha256: "8a14f238f28a0b54842c5a4dc20676598dd4811fcba284ed828bd5a262c11fde"
url: "https://pub.dev"
source: hosted
version: "2.1.0"
platform:
dependency: transitive
description:
Expand Down
7 changes: 2 additions & 5 deletions app/pubspec.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -37,12 +37,9 @@ dependencies:
material_leap:
git:
url: https://github.com/LinwoodDev/dart_pkgs
ref: 9338503df442df2e9a156511de1e93dfee8c4257
ref: 11a97be0a5bd85c14bdbb6555da8e84bbdd41ccb
path: packages/material_leap
phosphor_flutter:
git:
url: https://github.com/CodeDoctorDE/phosphor-flutter
ref: f370dd2c25d3ea51ffb8f1c7c183bc9f33889c82
phosphor_flutter: ^2.1.0
path: ^1.8.3
go_router: ^14.0.0
flex_color_scheme: ^7.3.1
Expand Down
1 change: 1 addition & 0 deletions fastlane/metadata/android/en-US/changelogs/7.txt
Original file line number Diff line number Diff line change
Expand Up @@ -13,5 +13,6 @@
* Unify select dialogs
* Upgrade to flutter 3.19
* Fix locale translations
* Fix week system in calendar week view

Read more here: https://linwood.dev/flow/0.3

0 comments on commit b5542f8

Please sign in to comment.