Skip to content

Commit

Permalink
Fix start of week
Browse files Browse the repository at this point in the history
  • Loading branch information
CodeDoctorDE committed Jul 28, 2023
1 parent 632ab34 commit 00e67c7
Show file tree
Hide file tree
Showing 7 changed files with 45 additions and 50 deletions.
3 changes: 1 addition & 2 deletions SECURITY.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,7 @@

| Version | Supported | |
| ------- | ------------------ | ------------------------------------------------------------------------------------------------------------------------------------------ |
| 2.0-dev | :warning: | [Docs](https://docs.flow.linwood.dev/docs/dev/intro) |
| 0.1.3 | :white_check_mark: | [Docs](https://docs.flow.linwood.dev/docs/dev/intro) [Release](https://github.com/LinwoodDev/Flow/releases/tag/v0.1.3) |
| 0.2.0 | :white_check_mark: | [Docs](https://docs.flow.linwood.dev/docs/dev/intro) [Release](https://github.com/LinwoodDev/Flow/releases/tag/v0.2.0) |

## Reporting a Vulnerability

Expand Down
31 changes: 13 additions & 18 deletions app/lib/pages/calendar/month.dart
Original file line number Diff line number Diff line change
Expand Up @@ -33,9 +33,9 @@ class CalendarMonthView extends StatefulWidget {

class _CalendarMonthViewState extends State<CalendarMonthView> {
late final FlowCubit _cubit;
int _month = 0, _year = 0;
int _month = 0, _year = 0, _startOfWeek = 0;
late final DateTime _now;
late Future<(int, List<List<SourcedConnectedModel<CalendarItem, Event?>>>)>
late Future<List<List<SourcedConnectedModel<CalendarItem, Event?>>>>
_appointments;

@override
Expand All @@ -45,6 +45,8 @@ class _CalendarMonthViewState extends State<CalendarMonthView> {
_cubit = context.read<FlowCubit>();
_month = _now.month;
_year = _now.year;
_startOfWeek = context.read<SettingsCubit>().state.startOfWeek;

_appointments = _fetchCalendarItems();
}

Expand All @@ -55,18 +57,14 @@ class _CalendarMonthViewState extends State<CalendarMonthView> {
_now.hour,
_now.minute,
_now.second,
).nextStartOfWeek.addDays(-7);
).nextStartOfWeek.addDays(-7 + _startOfWeek);

int _getDaysInView() => 6 * 7;

Future<(int, List<List<SourcedConnectedModel<CalendarItem, Event?>>>)>
Future<List<List<SourcedConnectedModel<CalendarItem, Event?>>>>
_fetchCalendarItems() async {
final startOfWeek = context.read<SettingsCubit>().state.startOfWeek;
if (!mounted) {
return (
startOfWeek,
<List<SourcedConnectedModel<CalendarItem, Event?>>>[]
);
return [];
}

var sources = _cubit.getCurrentServicesMap();
Expand All @@ -79,7 +77,7 @@ class _CalendarMonthViewState extends State<CalendarMonthView> {
final appointments = <List<SourcedConnectedModel<CalendarItem, Event?>>>[
for (int i = 0; i < days; i++) []
];
final date = _date.addDays(days);
final date = _date;
for (final source in sources.entries) {
for (int i = 0; i < days; i++) {
final fetchedDay = await source.value.calendarItem?.getCalendarItems(
Expand All @@ -98,7 +96,7 @@ class _CalendarMonthViewState extends State<CalendarMonthView> {
.addAll(fetchedDay.map((e) => SourcedModel(source.key, e)));
}
}
return (startOfWeek, appointments);
return appointments;
}

void _addMonth(int add) {
Expand Down Expand Up @@ -196,10 +194,7 @@ class _CalendarMonthViewState extends State<CalendarMonthView> {
]),
Expanded(
child: FutureBuilder<
(
int,
List<List<SourcedConnectedModel<CalendarItem, Event?>>>
)>(
List<List<SourcedConnectedModel<CalendarItem, Event?>>>>(
future: _appointments,
builder: (context, snapshot) {
if (snapshot.hasError) {
Expand All @@ -208,7 +203,7 @@ class _CalendarMonthViewState extends State<CalendarMonthView> {
if (!snapshot.hasData) {
return const Center(child: CircularProgressIndicator());
}
final (startOfWeek, appointments) = snapshot.data!;
final appointments = snapshot.data!;
return SingleChildScrollView(
child: GridView.builder(
shrinkWrap: true,
Expand All @@ -222,7 +217,7 @@ class _CalendarMonthViewState extends State<CalendarMonthView> {
if (index < 7) {
return LayoutBuilder(builder: (context, constraints) {
final current = _date.nextStartOfWeek
.addDays(index + startOfWeek);
.addDays(index + _startOfWeek);
var text = DateFormat.EEEE(locale).format(
current,
);
Expand All @@ -248,7 +243,7 @@ class _CalendarMonthViewState extends State<CalendarMonthView> {
}
final current = index - 7;
final day = _date.nextStartOfWeek
.addDays(current - 7 + startOfWeek);
.addDays(current - 7 + _startOfWeek);
return InkWell(
onTap: () async {
await showDialog(
Expand Down
5 changes: 2 additions & 3 deletions app/lib/pages/calendar/week.dart
Original file line number Diff line number Diff line change
Expand Up @@ -41,11 +41,11 @@ class _CalendarWeekViewState extends State<CalendarWeekView> {
void initState() {
super.initState();
_cubit = context.read<FlowCubit>();
_appointments = _fetchCalendarItems();
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)
Expand Down Expand Up @@ -212,8 +212,7 @@ class _CalendarWeekViewState extends State<CalendarWeekView> {
mainAxisSize: MainAxisSize.min,
children:
events.asMap().entries.map<Widget>((entry) {
final date =
_date.addDays(entry.key + _startOfWeek);
final date = _date.addDays(entry.key);
return Column(
children: [
// Weekday
Expand Down
4 changes: 2 additions & 2 deletions app/pubspec.lock
Original file line number Diff line number Diff line change
Expand Up @@ -1032,10 +1032,10 @@ packages:
dependency: "direct main"
description:
name: sqlite3
sha256: f7511ddd6a2dda8ded9d849f8a925bb6020e0faa59db2443debc18d484e59401
sha256: db65233e6b99e99b2548932f55a987961bc06d82a31a0665451fa0b4fff4c3fb
url: "https://pub.dev"
source: hosted
version: "2.0.0"
version: "2.1.0"
sqlite3_flutter_libs:
dependency: "direct main"
description:
Expand Down
2 changes: 1 addition & 1 deletion app/pubspec.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -61,7 +61,7 @@ dependencies:
sqflite_common_ffi: ^2.3.0
sqflite_common_ffi_web: ^0.4.0
sqlite3_flutter_libs: ^0.5.15
sqlite3: ^2.0.0
sqlite3: ^2.1.0
dynamic_color: ^1.6.6
simple_icons: ^7.10.0
flutter_localized_locales: ^2.0.4
Expand Down
46 changes: 23 additions & 23 deletions docs/yarn.lock
Original file line number Diff line number Diff line change
Expand Up @@ -3134,13 +3134,13 @@ __metadata:
linkType: hard

"@types/react@npm:*":
version: 18.2.16
resolution: "@types/react@npm:18.2.16"
version: 18.2.17
resolution: "@types/react@npm:18.2.17"
dependencies:
"@types/prop-types": "*"
"@types/scheduler": "*"
csstype: ^3.0.2
checksum: 3d4fdc12509e0098e0dbb4bacdea53e8ccc6632e9df63d9f2711c77aa81ce3b2bb9c76d087f284034b25fd7245680167f4832bf6e4df960c5af2634b52adfd0c
checksum: 150516b31bd98b635e4a56bcf2af007330b35cccb6e35e902f46a47f0e81e30c46cdacc095e91051bdf2f33e4846e7e62fd51b67e064dc7d15c00e15dfa449d5
languageName: node
linkType: hard

Expand Down Expand Up @@ -4625,25 +4625,25 @@ __metadata:
linkType: hard

"core-js-compat@npm:^3.31.0":
version: 3.31.1
resolution: "core-js-compat@npm:3.31.1"
version: 3.32.0
resolution: "core-js-compat@npm:3.32.0"
dependencies:
browserslist: ^4.21.9
checksum: 9a16d6992621f4e099169297381a28d5712cdef7df1fa85352a7c285a5885d5d7a117ec2eae9ad715ed88c7cc774787a22cdb8aceababf6775fbc8b0cbeccdb7
checksum: e740b348dfd8dc25ac851ab625a1d5a63c012252bdd6d8ae92d1b2ebf46e6cf57ca6cbec4494cbacdd90d3f8ed822480c8a7106c990dbe9055ebdf5b79fbb92e
languageName: node
linkType: hard

"core-js-pure@npm:^3.30.2":
version: 3.31.1
resolution: "core-js-pure@npm:3.31.1"
checksum: 93c3dd28471755cb81ec4828f5617bd32a7c682295d88671534a6733a0d41dae9e28f8f8000ddd1f1e597a3bec4602db5f906a03c9ba1a360534f7ae2519db7c
version: 3.32.0
resolution: "core-js-pure@npm:3.32.0"
checksum: 57b1ae97e6d468dfa34af3df75bba3fec3d01a04392f7c11f77a698f7157be199b647c599a06869fb403397a2e512dbbfc6eb3b8a690f857484125620f7d36e6
languageName: node
linkType: hard

"core-js@npm:^3.23.3":
version: 3.31.1
resolution: "core-js@npm:3.31.1"
checksum: 14519213a63c55cf188bdd2f4dece54583feaf6b90e75d6c65e07f509cd487055bf64898aeda7c97c36029ac1ea2f2ed8e4b02281553f6a257e7143a32a14015
version: 3.32.0
resolution: "core-js@npm:3.32.0"
checksum: 52921395028550e4c9d21d47b9836439bb5b6b9eefc34d45a3948a68d81fdd093acc0fadf69f9cf632b82f01f95f22f484408a93dd9e940b19119ac204cd2925
languageName: node
linkType: hard

Expand Down Expand Up @@ -5245,9 +5245,9 @@ __metadata:
linkType: hard

"electron-to-chromium@npm:^1.4.431":
version: 1.4.471
resolution: "electron-to-chromium@npm:1.4.471"
checksum: c62ac1f2e9e0395b3095899c7d07a723611a6ca9bc754935101f9f659d7fc3f564f4e47cacb5639abdc172265db041923679942c72055fc8d6522e1b57f755df
version: 1.4.475
resolution: "electron-to-chromium@npm:1.4.475"
checksum: 3e7a538c486b351c13bcd05295535b2b5b0a2980dcf3504457fe47c6689d74a87fd62eab629227dcc86b66cfd732076667d6392f998b13995a8b54eff8073fb8
languageName: node
linkType: hard

Expand Down Expand Up @@ -7352,17 +7352,17 @@ __metadata:
languageName: node
linkType: hard

"jest-util@npm:^29.6.1":
version: 29.6.1
resolution: "jest-util@npm:29.6.1"
"jest-util@npm:^29.6.2":
version: 29.6.2
resolution: "jest-util@npm:29.6.2"
dependencies:
"@jest/types": ^29.6.1
"@types/node": "*"
chalk: ^4.0.0
ci-info: ^3.2.0
graceful-fs: ^4.2.9
picomatch: ^2.2.3
checksum: fc553556c1350c443449cadaba5fb9d604628e8b5ceb6ceaf4e7e08975b24277d0a14bf2e0f956024e03c23e556fcb074659423422a06fbedf2ab52978697ac7
checksum: 8aedc0c80083d0cabd6c6c4f04dea1cbcac609fd7bc3b1fc05a3999291bd6e63dd52b0c806f9378d5cae28eff5a6191709a4987861001293f8d03e53984adca4
languageName: node
linkType: hard

Expand All @@ -7389,14 +7389,14 @@ __metadata:
linkType: hard

"jest-worker@npm:^29.1.2":
version: 29.6.1
resolution: "jest-worker@npm:29.6.1"
version: 29.6.2
resolution: "jest-worker@npm:29.6.2"
dependencies:
"@types/node": "*"
jest-util: ^29.6.1
jest-util: ^29.6.2
merge-stream: ^2.0.0
supports-color: ^8.0.0
checksum: 0af309ea4db17c4c47e84a9246f907960a15577683c005fdeafc8f3c06bc455136f95a6f28fa2a3e924b767eb4dacd9b40915a7707305f88586f099af3ac27a8
checksum: 11035564534bf181ead80b25be138c2d42372bd5626151a3e705200d47a74fd9da3ca79f8a7b15806cdc325ad73c3d21d23acceeed99d50941589ff02915ed38
languageName: node
linkType: hard

Expand Down
4 changes: 3 additions & 1 deletion fastlane/metadata/android/en-US/changelogs/5.txt
Original file line number Diff line number Diff line change
Expand Up @@ -13,4 +13,6 @@
* Fix month view
* Fix ical importer for start date time
* Fix internet permission on android
* Upgrade to flutter 3.10
* Upgrade to flutter 3.10

View all changes in the blog: https://linwood.dev/flow/0.2

0 comments on commit 00e67c7

Please sign in to comment.