Skip to content

Commit 9b65cfc

Browse files
committed
Syncfusion calendar renamed to Simple event calendar and initial page UI improved.
1 parent ceda63d commit 9b65cfc

File tree

4 files changed

+64
-35
lines changed

4 files changed

+64
-35
lines changed

android/app/src/main/AndroidManifest.xml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@
77
FlutterApplication and put your custom class here. -->
88
<application
99
android:name="io.flutter.app.FlutterApplication"
10-
android:label="syncfusioncalendar"
10+
android:label="Simple Event Calendar"
1111
android:icon="@mipmap/ic_launcher">
1212
<activity
1313
android:name=".MainActivity"

lib/calendar_data.dart

Lines changed: 15 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -27,14 +27,12 @@ class _LoadingStream {
2727
}
2828

2929
class CalendarData {
30-
CalendarData(GoogleDataSource dataSource, VoidCallback updateCalendarUI) {
31-
loadFirebase(dataSource, updateCalendarUI);
30+
CalendarData() {
31+
loadFirebase();
3232
}
3333

34-
void loadFirebase(
35-
GoogleDataSource dataSource, VoidCallback updateCalendarUI) async {
34+
void loadFirebase() async {
3635
_auth = auth.FirebaseAuth.instance;
37-
refresh(dataSource, updateCalendarUI);
3836
}
3937

4038
final DatabaseHelper db =
@@ -326,6 +324,11 @@ class CalendarData {
326324

327325
Future<void> updateSettingFromDB(VoidCallback updateCalendarUI) async {
328326
if (kIsWeb) {
327+
currentUser.value = await _auth.currentUser();
328+
if (currentUser.value != null) {
329+
googleUser ??= await _googleSignIn.signInSilently();
330+
}
331+
329332
await _initializeSettings(updateCalendarUI);
330333
return;
331334
}
@@ -347,12 +350,14 @@ class CalendarData {
347350
showArrows = false;
348351
}
349352

353+
if (updateCalendarUI == null) {
354+
return;
355+
}
350356
updateCalendarUI();
351357
}
352358

353359
void refresh(
354360
GoogleDataSource dataSource, VoidCallback updateCalendarUI) async {
355-
updateSettingFromDB(updateCalendarUI);
356361
if (kIsWeb) {
357362
loadingStream.send.add(true);
358363
currentUser.value = await _auth.currentUser();
@@ -362,6 +367,7 @@ class CalendarData {
362367
}
363368
loadingStream.send.add(false);
364369
} else {
370+
updateSettingFromDB(updateCalendarUI);
365371
loadExistingAppointments(dataSource, updateCalendarUI);
366372
}
367373
}
@@ -519,6 +525,9 @@ class CalendarData {
519525
}
520526

521527
await getFirebaseData();
528+
if (updateCalendarUI == null) {
529+
return;
530+
}
522531
updateCalendarUI();
523532
}
524533

lib/main.dart

Lines changed: 47 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@ class MyApp extends StatelessWidget {
1818
Widget build(BuildContext context) {
1919
return MaterialApp(
2020
debugShowCheckedModeBanner: false,
21-
title: 'Customized Calendar',
21+
title: 'Simple Event Calendar',
2222
theme: ThemeData(
2323
primarySwatch: Colors.blue,
2424
visualDensity: VisualDensity.adaptivePlatformDensity,
@@ -49,7 +49,8 @@ class _MyHomePageState extends State<MyHomePage> {
4949
@override
5050
void initState() {
5151
_dataSource = GoogleDataSource();
52-
calendarData = CalendarData(_dataSource, updateUI);
52+
calendarData = CalendarData();
53+
calendarData.refresh(_dataSource, updateUI);
5354
_isDBLoaded = false;
5455
calendarData.updateSettingFromDB(updateUI)
5556
..then((value) {
@@ -95,7 +96,8 @@ class _MyHomePageState extends State<MyHomePage> {
9596
calendarTapDetails.targetElement == CalendarElement.allDayPanel;
9697
DateTime _selectedDate;
9798

98-
if (_controller.view == CalendarView.month && calendarTapDetails.targetElement != CalendarElement.appointment) {
99+
if (_controller.view == CalendarView.month &&
100+
calendarTapDetails.targetElement != CalendarElement.appointment) {
99101
setState(() {
100102
/// Update the draw content when calendar view changed.
101103
_controller.view = CalendarView.day;
@@ -259,7 +261,8 @@ class _MyHomePageState extends State<MyHomePage> {
259261
),
260262
onTap: (() async {
261263
showDialog(
262-
context: context,barrierDismissible: false,
264+
context: context,
265+
barrierDismissible: false,
263266
builder: (BuildContext context) {
264267
return Center(
265268
child: CircularProgressIndicator(),
@@ -429,20 +432,44 @@ class _MyHomePageState extends State<MyHomePage> {
429432
body: Container(
430433
color: Colors.white,
431434
alignment: Alignment.center,
432-
child: Row(
433-
mainAxisAlignment: MainAxisAlignment.center,
434-
crossAxisAlignment: CrossAxisAlignment.center,
435-
children: [
436-
Icon(
437-
Icons.widgets,
438-
color: Colors.black54,
439-
),
440-
Text(
441-
' Syncfusion Calendar',
442-
style: TextStyle(fontSize: 20),
443-
),
444-
],
445-
)),
435+
child: Column(children: [
436+
Expanded(
437+
child: Column(
438+
mainAxisAlignment: MainAxisAlignment.center,
439+
crossAxisAlignment: CrossAxisAlignment.center,
440+
children: [
441+
Icon(
442+
Icons.date_range,
443+
color: Colors.black54,
444+
size: 40,
445+
),
446+
Padding(
447+
padding: EdgeInsets.only(top: 5),
448+
child: Text(
449+
' Simple Event Calendar',
450+
style: TextStyle(fontSize: 22),
451+
)),
452+
],
453+
)),
454+
Container(
455+
padding: EdgeInsets.symmetric(vertical: 5),
456+
child: Text(
457+
'From',
458+
style: TextStyle(
459+
color: Colors.black54,
460+
fontSize: 14,
461+
fontWeight: FontWeight.w500),
462+
)),
463+
Container(
464+
padding: EdgeInsets.only(bottom: 30),
465+
child: Text(
466+
'Syncfusion',
467+
style: TextStyle(
468+
color: Colors.deepOrange,
469+
fontSize: 22,
470+
fontWeight: FontWeight.w500),
471+
))
472+
])),
446473
)
447474
: Scaffold(
448475
drawer: Container(
@@ -459,7 +486,8 @@ class _MyHomePageState extends State<MyHomePage> {
459486
text: 'Sign out',
460487
onTap: (() async {
461488
showDialog(
462-
context: context,barrierDismissible: false,
489+
context: context,
490+
barrierDismissible: false,
463491
builder: (BuildContext context) {
464492
return Center(
465493
child: CircularProgressIndicator(),

pubspec.yaml

Lines changed: 1 addition & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -24,20 +24,14 @@ dependencies:
2424
flutter:
2525
sdk: flutter
2626

27-
28-
# The following adds the Cupertino Icons font to your application.
29-
# Use with the CupertinoIcons class for iOS style icons.
30-
cupertino_icons: ^0.1.3
3127
googleapis: ^0.54.0
3228
cloud_firestore: ^0.13.5
3329
google_sign_in: ^4.4.6
3430
firebase_auth: ^0.16.0
3531
firebase_auth_web:
3632
sqflite:
3733
path_provider:
38-
syncfusion_flutter_calendar:
39-
path: /Users/SasikumarArumugam/Desktop/Sasi/2020/Flutter-Calendar/Oct-13 Navigation Animation Improvement/flutter_calendar/syncfusion_flutter_calendar
40-
# ^18.4.30
34+
syncfusion_flutter_calendar: ^18.4.30
4135

4236
dev_dependencies:
4337
flutter_test:
@@ -60,9 +54,7 @@ flutter:
6054
# - images/a_dot_ham.jpeg
6155

6256
assets:
63-
- assets/
6457
- assets/images/
65-
- assets/images/syncfusion.png
6658

6759
# An image asset can refer to one or more resolution-specific "variants", see
6860
# https://flutter.dev/assets-and-images/#resolution-aware.

0 commit comments

Comments
 (0)