changes local

dev_v3.13.6_BLE_Faiz
Aamir Muhammad 2 years ago
parent 660ec3a207
commit e18ba6822a

@ -59,7 +59,7 @@ class AppointmentActions extends StatefulWidget {
class _AppointmentActionsState extends State<AppointmentActions> { class _AppointmentActionsState extends State<AppointmentActions> {
List<AppoDetailsButton> appoButtonsList = []; List<AppoDetailsButton> appoButtonsList = [];
static bool isHuawei = false; static bool isHuawei = false;
late HmsApiAvailability hmsApiAvailability; HmsApiAvailability hmsApiAvailability = HmsApiAvailability();
@override @override
void initState() { void initState() {

@ -1,17 +1,19 @@
import 'dart:async'; import 'dart:async';
import 'dart:convert';
import 'dart:io';
import 'dart:ui'; import 'dart:ui';
import 'package:device_calendar/device_calendar.dart'; import 'package:device_calendar/device_calendar.dart';
import 'package:manage_calendar_events/manage_calendar_events.dart' as mcn; import 'package:manage_calendar_events/manage_calendar_events.dart' as ios;
final DeviceCalendarPlugin deviceCalendarPlugin = DeviceCalendarPlugin(); final DeviceCalendarPlugin deviceCalendarPlugin = DeviceCalendarPlugin();
final mcn.CalendarPlugin _myPlugin = mcn.CalendarPlugin(); final ios.CalendarPlugin _myPlugin = ios.CalendarPlugin();
class CalendarUtils { class CalendarUtils {
static Completer<CalendarUtils>? _completer; static Completer<CalendarUtils>? _completer;
mcn.Calendar? get writableCalendars => calendars.firstWhere((c) => !c.isReadOnly!); dynamic get writableCalendars => calendars.firstWhere((c) => !c.isReadOnly!);
List<mcn.Calendar> calendars; dynamic calendars;
CalendarUtils._(this.calendars); CalendarUtils._(this.calendars);
@ -21,9 +23,15 @@ class CalendarUtils {
if (_completer == null) { if (_completer == null) {
_completer = await Completer<CalendarUtils>(); _completer = await Completer<CalendarUtils>();
try { try {
final List<mcn.Calendar>? calendarsResult = await _myPlugin.getCalendars(); final dynamic calendarsResult;
// if (calendarsResult.data != null) if (Platform.isIOS) {
_completer?.complete(await CalendarUtils._(await calendarsResult!)); calendarsResult = await _myPlugin.getCalendars();
_completer?.complete(await CalendarUtils._(await calendarsResult!));
} else {
calendarsResult = await deviceCalendarPlugin.retrieveCalendars();
print(jsonEncode(calendarsResult.data!));
_completer?.complete(await CalendarUtils._(await calendarsResult.data!));
}
} on Exception catch (e) { } on Exception catch (e) {
_completer!.completeError(e); _completer!.completeError(e);
final Future<CalendarUtils> sharedPrefsFuture = _completer!.future; final Future<CalendarUtils> sharedPrefsFuture = _completer!.future;
@ -31,6 +39,7 @@ class CalendarUtils {
return sharedPrefsFuture; return sharedPrefsFuture;
} }
} }
return _completer!.future; return _completer!.future;
} }
@ -78,11 +87,18 @@ class CalendarUtils {
TZDateTime scheduleDateTimeUTZ = TZDateTime.from(scheduleDateTime!, _currentLocation); TZDateTime scheduleDateTimeUTZ = TZDateTime.from(scheduleDateTime!, _currentLocation);
// print("eventId: " + eventId); print("eventId: " + "hhgvhg");
// print("writableCalendars-name: " + writableCalendars.name); // print("writableCalendars-name: " + writableCalendars.name);
// print("writableCalendars-Id: " + writableCalendars.id); // print("writableCalendars-Id: " + writableCalendars.id);
// print("writableCalendarsToString: " + writableCalendars.toString()); print("writableCalendarsToString: " + writableCalendars.toString());
Event event = Event(writableCalendars!.id, start: scheduleDateTimeUTZ, end: scheduleDateTimeUTZ.add(Duration(minutes: 30)), title: title, description: description); print("writableCalendarsToString: " + writableCalendars!.id!);
Event event = await Event(
writableCalendars!.id,
start: scheduleDateTimeUTZ,
end: scheduleDateTimeUTZ.add(Duration(minutes: 30)),
title: title,
description: description,
);
deviceCalendarPlugin.createOrUpdateEvent(event).catchError((e) { deviceCalendarPlugin.createOrUpdateEvent(event).catchError((e) {
print("catchError " + e.toString()); print("catchError " + e.toString());
}).whenComplete(() { }).whenComplete(() {
@ -90,8 +106,12 @@ class CalendarUtils {
}); });
} }
deleteEvent(mcn.Calendar _calendar, Event _event) async { deleteEvent(Calendar _calendar, Event _event) async {
await deviceCalendarPlugin.deleteEvent(_calendar.id, _event.eventId); if (Platform.isIOS) {
await _myPlugin.deleteEvent(calendarId: _calendar.id!, eventId: _event.eventId!);
} else {
await deviceCalendarPlugin.deleteEvent(_calendar.id, _event.eventId);
}
} }
Future retrieveEvents( Future retrieveEvents(

Loading…
Cancel
Save