Skip to content

Commit

Permalink
1) Delete unnecessary TODOs; 2) Solve wrong Function signature in exa…
Browse files Browse the repository at this point in the history
…mple (event_item.dart & recurring_event_dialog.dart); 3) Updated dependencies in pubspec.yaml; 4) Correct typos;
  • Loading branch information
GoldenSoju committed Oct 5, 2022
1 parent 6029acf commit 8cd7d14
Show file tree
Hide file tree
Showing 6 changed files with 24 additions and 22 deletions.
1 change: 1 addition & 0 deletions example/analysis_options.yaml
Original file line number Diff line number Diff line change
@@ -1,2 +1,3 @@
include: package:pedantic/analysis_options.yaml
#include: package:flutter_lints/flutter.yaml
# TODO: change to flutter lints (https://pub.dev/packages/flutter_lints)
2 changes: 0 additions & 2 deletions example/android/app/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,6 @@ android {
}

defaultConfig {
// TODO: Specify your own unique Application ID (https://developer.android.com/studio/build/application-id.html).
applicationId "com.builttoroam.devicecalendarexample"
minSdkVersion 16
targetSdkVersion 31
Expand All @@ -41,7 +40,6 @@ android {
release {
minifyEnabled true
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
// TODO: Add your own signing config for the release build.
// Signing with the debug keys for now, so `flutter run --release` works.
signingConfig signingConfigs.debug
}
Expand Down
7 changes: 4 additions & 3 deletions example/lib/presentation/event_item.dart
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ class EventItem extends StatefulWidget {

final Function(Event) _onTapped;
final VoidCallback _onLoadingStarted;
final Function(bool) _onDeleteFinished;
final Function(BuildContext, bool) _onDeleteFinished;

EventItem(
this._calendarEvent,
Expand All @@ -40,7 +40,7 @@ class _EventItemState extends State<EventItem> {
@override
void initState() {
super.initState();
WidgetsBinding.instance.addPostFrameCallback((_) => setCurentLocation());
WidgetsBinding.instance.addPostFrameCallback((_) => setCurrentLocation());
}

@override
Expand Down Expand Up @@ -271,6 +271,7 @@ class _EventItemState extends State<EventItem> {
widget._calendarEvent?.calendarId,
widget._calendarEvent?.eventId);
widget._onDeleteFinished(
context,
deleteResult.isSuccess &&
deleteResult.data != null);
},
Expand Down Expand Up @@ -311,7 +312,7 @@ class _EventItemState extends State<EventItem> {
);
}

void setCurentLocation() async {
void setCurrentLocation() async {
String? timezone;
try {
timezone = await FlutterNativeTimezone.getLocalTimezone();
Expand Down
17 changes: 9 additions & 8 deletions example/lib/presentation/pages/calendar_event.dart
Original file line number Diff line number Diff line change
Expand Up @@ -4,14 +4,14 @@ import 'package:collection/collection.dart';
import 'package:device_calendar/device_calendar.dart';
import 'package:flutter/material.dart';
import 'package:flutter/services.dart';
import 'package:flutter_native_timezone/flutter_native_timezone.dart';
import 'package:intl/intl.dart';
import 'package:timezone/timezone.dart';

import '../date_time_picker.dart';
import '../recurring_event_dialog.dart';
import 'event_attendee.dart';
import 'event_reminders.dart';
import 'package:timezone/timezone.dart';
import 'package:flutter_native_timezone/flutter_native_timezone.dart';

enum RecurrenceRuleEndType { Indefinite, MaxOccurrences, SpecifiedEndDate }

Expand Down Expand Up @@ -66,10 +66,10 @@ class _CalendarEventPageState extends State<CalendarEventPage> {

_CalendarEventPageState(
this._calendar, this._event, this._recurringEventDialog) {
getCurentLocation();
getCurrentLocation();
}

void getCurentLocation() async {
void getCurrentLocation() async {
try {
_timezone = await FlutterNativeTimezone.getLocalTimezone();
} catch (e) {
Expand Down Expand Up @@ -776,7 +776,7 @@ class _CalendarEventPageState extends State<CalendarEventPage> {
},
value: WeekNumber.values.toList()[
(_rrule?.hasByWeekDays ?? false)
? _weekNumFromWeekDayOccurence(
? _weekNumFromWeekDayOccurrence(
_rrule!.byWeekDays)
: 0],
items: WeekNumber.values
Expand Down Expand Up @@ -923,7 +923,7 @@ class _CalendarEventPageState extends State<CalendarEventPage> {
),
],
...[
// TODO: on iPhone (e.g. 8) this seems neccesary to be able to access UI below the FAB
// TODO: on iPhone (e.g. 8) this seems necessary to be able to access UI below the FAB
const SizedBox(height: 75),
]
],
Expand All @@ -934,7 +934,8 @@ class _CalendarEventPageState extends State<CalendarEventPage> {
ElevatedButton(
key: const Key('deleteEventButton'),
style: ElevatedButton.styleFrom(
primary: Colors.red, onPrimary: Colors.white),
foregroundColor: Colors.white,
backgroundColor: Colors.red),
onPressed: () async {
bool? result = true;
if (!(_rrule != null)) {
Expand Down Expand Up @@ -1137,7 +1138,7 @@ class _CalendarEventPageState extends State<CalendarEventPage> {
}
}

int _weekNumFromWeekDayOccurence(Set<ByWeekDayEntry> weekdays) {
int _weekNumFromWeekDayOccurrence(Set<ByWeekDayEntry> weekdays) {
final weekNum = weekdays.first.occurrence;
if (weekNum != null) {
return weekNum - 1;
Expand Down
15 changes: 8 additions & 7 deletions example/lib/presentation/recurring_event_dialog.dart
Original file line number Diff line number Diff line change
@@ -1,12 +1,12 @@
import 'package:flutter/material.dart';
import 'package:device_calendar/device_calendar.dart';
import 'package:flutter/material.dart';

class RecurringEventDialog extends StatefulWidget {
final DeviceCalendarPlugin _deviceCalendarPlugin;
final Event _calendarEvent;

final VoidCallback _onLoadingStarted;
final Function(bool) _onDeleteFinished;
final Function(BuildContext, bool) _onDeleteFinished;

RecurringEventDialog(this._deviceCalendarPlugin, this._calendarEvent,
this._onLoadingStarted, this._onDeleteFinished,
Expand All @@ -24,11 +24,12 @@ class _RecurringEventDialogState extends State<RecurringEventDialog> {
late DeviceCalendarPlugin _deviceCalendarPlugin;
late Event _calendarEvent;
VoidCallback? _onLoadingStarted;
Function(bool)? _onDeleteFinished;
Function(BuildContext, bool)? _onDeleteFinished;

_RecurringEventDialogState(
DeviceCalendarPlugin deviceCalendarPlugin, Event calendarEvent,
{VoidCallback? onLoadingStarted, Function(bool)? onDeleteFinished}) {
{VoidCallback? onLoadingStarted,
Function(BuildContext, bool)? onDeleteFinished}) {
_deviceCalendarPlugin = deviceCalendarPlugin;
_calendarEvent = calendarEvent;
_onLoadingStarted = onLoadingStarted;
Expand All @@ -53,7 +54,7 @@ class _RecurringEventDialogState extends State<RecurringEventDialog> {
false);
if (_onDeleteFinished != null) {
_onDeleteFinished!(
deleteResult.isSuccess && deleteResult.data != null);
context, deleteResult.isSuccess && deleteResult.data != null);
}
},
child: Text('This instance only'),
Expand All @@ -71,7 +72,7 @@ class _RecurringEventDialogState extends State<RecurringEventDialog> {
true);
if (_onDeleteFinished != null) {
_onDeleteFinished!(
deleteResult.isSuccess && deleteResult.data != null);
context, deleteResult.isSuccess && deleteResult.data != null);
}
},
child: Text('This and following instances'),
Expand All @@ -84,7 +85,7 @@ class _RecurringEventDialogState extends State<RecurringEventDialog> {
_calendarEvent.calendarId, _calendarEvent.eventId);
if (_onDeleteFinished != null) {
_onDeleteFinished!(
deleteResult.isSuccess && deleteResult.data != null);
context, deleteResult.isSuccess && deleteResult.data != null);
}
},
child: Text('All instances'),
Expand Down
4 changes: 2 additions & 2 deletions pubspec.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -7,11 +7,11 @@ dependencies:
flutter:
sdk: flutter
collection: ^1.16.0
sprintf: ^6.0.2
sprintf: ^7.0.0
timezone: ^0.9.0
flutter_native_timezone: ^2.0.0
intl: ^0.17.0
rrule: ^0.2.7
rrule: ^0.2.10

dev_dependencies:
flutter_test:
Expand Down

0 comments on commit 8cd7d14

Please sign in to comment.