Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Timezone implementation #297

Merged
merged 17 commits into from
May 11, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -141,7 +141,7 @@ class CalendarDelegate : PluginRegistry.RequestPermissionsResultListener {
createOrUpdateEvent(cachedValues.calendarId, cachedValues.event, cachedValues.pendingChannelResult)
}
DELETE_EVENT_REQUEST_CODE -> {
deleteEvent(cachedValues.eventId, cachedValues.calendarId, cachedValues.pendingChannelResult)
deleteEvent(cachedValues.calendarId, cachedValues.eventId, cachedValues.pendingChannelResult)
}
REQUEST_PERMISSIONS_REQUEST_CODE -> {
finishWithSuccess(permissionGranted, cachedValues.pendingChannelResult)
Expand Down Expand Up @@ -477,13 +477,9 @@ class CalendarDelegate : PluginRegistry.RequestPermissionsResultListener {
calendar.set(java.util.Calendar.SECOND, 0)
calendar.set(java.util.Calendar.MILLISECOND, 0)

// All day events must have UTC timezone
val utcTimeZone = TimeZone.getTimeZone("UTC")
calendar.timeZone = utcTimeZone

values.put(Events.DTSTART, calendar.timeInMillis)
values.put(Events.DTEND, calendar.timeInMillis)
values.put(Events.EVENT_TIMEZONE, utcTimeZone.id)
values.put(Events.EVENT_TIMEZONE, getTimeZone(event.startTimeZone).id)
} else {
values.put(Events.DTSTART, event.start!!)
values.put(Events.EVENT_TIMEZONE, getTimeZone(event.startTimeZone).id)
Expand Down
2 changes: 1 addition & 1 deletion example/android/app/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ apply from: "$flutterRoot/packages/flutter_tools/gradle/flutter.gradle"

android {
compileSdkVersion 29
ndkVersion '21.4.7075529'
ndkVersion '22.1.7171670'

sourceSets {
main.java.srcDirs += 'src/main/kotlin'
Expand Down
1 change: 1 addition & 0 deletions example/ios/.gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -41,4 +41,5 @@ Icon?
/Flutter/Generated.xcconfig
/ServiceDefinitions.json

**/.symlinks/
Pods/
1 change: 0 additions & 1 deletion example/ios/.symlinks/plugins/device_calendar

This file was deleted.

6 changes: 6 additions & 0 deletions example/ios/Podfile.lock
Original file line number Diff line number Diff line change
Expand Up @@ -2,20 +2,26 @@ PODS:
- device_calendar (0.0.1):
- Flutter
- Flutter (1.0.0)
- flutter_native_timezone (0.0.1):
- Flutter

DEPENDENCIES:
- device_calendar (from `.symlinks/plugins/device_calendar/ios`)
- Flutter (from `Flutter`)
- flutter_native_timezone (from `.symlinks/plugins/flutter_native_timezone/ios`)

EXTERNAL SOURCES:
device_calendar:
:path: ".symlinks/plugins/device_calendar/ios"
Flutter:
:path: Flutter
flutter_native_timezone:
:path: ".symlinks/plugins/flutter_native_timezone/ios"

SPEC CHECKSUMS:
device_calendar: 23b28a5f1ab3bf77e34542fb1167e1b8b29a98f5
Flutter: 434fef37c0980e73bb6479ef766c45957d4b510c
flutter_native_timezone: 5f05b2de06c9776b4cc70e1839f03de178394d22

PODFILE CHECKSUM: aafe91acc616949ddb318b77800a7f51bffa2a4c

Expand Down
4 changes: 2 additions & 2 deletions example/ios/Runner.xcodeproj/project.pbxproj
Original file line number Diff line number Diff line change
Expand Up @@ -213,10 +213,12 @@
inputPaths = (
"${PODS_ROOT}/Target Support Files/Pods-Runner/Pods-Runner-frameworks.sh",
"${BUILT_PRODUCTS_DIR}/device_calendar/device_calendar.framework",
"${BUILT_PRODUCTS_DIR}/flutter_native_timezone/flutter_native_timezone.framework",
);
name = "[CP] Embed Pods Frameworks";
outputPaths = (
"${TARGET_BUILD_DIR}/${FRAMEWORKS_FOLDER_PATH}/device_calendar.framework",
"${TARGET_BUILD_DIR}/${FRAMEWORKS_FOLDER_PATH}/flutter_native_timezone.framework",
);
runOnlyForDeploymentPostprocessing = 0;
shellPath = /bin/sh;
Expand Down Expand Up @@ -431,7 +433,6 @@
"$(inherited)",
"$(PROJECT_DIR)/Flutter",
);
// change the id at debug to avoid error
PRODUCT_BUNDLE_IDENTIFIER = com.builttoroam.deviceCalendarExample00;
PRODUCT_NAME = "$(TARGET_NAME)";
PROVISIONING_PROFILE_SPECIFIER = "";
Expand Down Expand Up @@ -464,7 +465,6 @@
"$(inherited)",
"$(PROJECT_DIR)/Flutter",
);
// change the id at debug to avoid error
PRODUCT_BUNDLE_IDENTIFIER = com.builttoroam.deviceCalendarExample00;
PRODUCT_NAME = "$(TARGET_NAME)";
PROVISIONING_PROFILE_SPECIFIER = "";
Expand Down
12 changes: 8 additions & 4 deletions example/lib/presentation/date_time_picker.dart
Original file line number Diff line number Diff line change
Expand Up @@ -26,15 +26,19 @@ class DateTimePicker extends StatelessWidget {
Future<Null> _selectDate(BuildContext context) async {
final picked = await showDatePicker(
context: context,
initialDate: selectedDate != null ? selectDate as DateTime : DateTime.now(),
initialDate: selectedDate != null
? DateTime.parse(selectedDate.toString())
: DateTime.now(),
firstDate: DateTime(2015, 8),
lastDate: DateTime(2101));
if (picked != null && picked != selectedDate && selectDate != null) selectDate!(picked);
if (picked != null && picked != selectedDate && selectDate != null)
selectDate!(picked);
}

Future<Null> _selectTime(BuildContext context) async {
if(selectedTime == null) return;
final picked = await showTimePicker(context: context, initialTime: selectedTime!);
if (selectedTime == null) return;
final picked =
await showTimePicker(context: context, initialTime: selectedTime!);
if (picked != null && picked != selectedTime) selectTime!(picked);
}

Expand Down
Loading