-
Notifications
You must be signed in to change notification settings - Fork 4
/
Copy pathevents.dart
180 lines (173 loc) · 5.88 KB
/
events.dart
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
import 'package:url_launcher/url_launcher.dart';
import 'package:flutter/cupertino.dart';
import 'package:flutter/material.dart';
import 'package:flutter_svg/flutter_svg.dart';
import 'package:campusbuddy/notification.dart';
import 'package:campusbuddy/calendar.dart';
import 'package:flutter_linkify/flutter_linkify.dart';
import 'dart:async';
import 'gmaps.dart';
//Class that fetches and stores all details of added Events and Posts from Firestore.
class Deets {
String title, venue, desc, imgURL, group;
double longitude, latitude; //in console use double values, i.e: use 2.0 not 2
DateTime time;
Deets(this.title, this.time, this.venue, this.desc, this.imgURL, this.group,
this.longitude, this.latitude);
}
class Events extends StatefulWidget {
final Deets eventsDeets;
Events(this.eventsDeets, {Key key}) : super(key: key);
static const routeName = "/events";
@override
_EventsState createState() => _EventsState(eventsDeets);
}
class _EventsState extends State<Events> {
static const Color black = const Color(0xff242424);
static const Color indigo = const Color(0xff303E84);
Deets deets;
_EventsState(this.deets);
@override
Widget build(BuildContext context) {
return Scaffold(
body: CustomScrollView(
slivers: <Widget>[
SliverAppBar(
floating: true,
pinned: true,
snap: true,
expandedHeight: 210.0,
backgroundColor: indigo,
flexibleSpace: FlexibleSpaceBar(
centerTitle: true,
title: Padding(
padding: const EdgeInsets.fromLTRB(20, 2, 20, 2),
child: Text(
'${deets.group}',
style: TextStyle(
fontSize: 14,
fontWeight: FontWeight.w500,
fontFamily: 'Roboto',
color: Colors.white,
),
overflow: TextOverflow.ellipsis,
),
),
background: Center(
child: Container(
width: 120,
height: 120,
decoration: (deets.imgURL == null || deets.imgURL == '')
? new BoxDecoration()
: new BoxDecoration(
shape: BoxShape.circle,
image: new DecorationImage(
fit: BoxFit.cover,
image: NetworkImage(deets.imgURL),
)),
),
),
),
),
SliverToBoxAdapter(
child: Material(
color: Colors.white,
child: Container(
height: 1000,
child: Column(
children: <Widget>[
Padding(
padding: const EdgeInsets.fromLTRB(10, 20, 0, 10),
child: Row(
children: <Widget>[
Expanded(
child: Container(
child: Text(deets.title,
textAlign: TextAlign.left,
style: TextStyle(
color: indigo,
fontSize: 30,
fontWeight: FontWeight.w500,
fontFamily: 'Roboto')),
),
flex: 4,
),
Expanded(
child: IconButton(
icon: new SvgPicture.asset(
'assets/facebookLogo.svg'),
iconSize: 40,
onPressed: _launchURL,
),
flex: 1,
),
],
),
),
Padding(
padding: const EdgeInsets.all(10.0),
child: Linkify(
onOpen: _onOpen,
text: "${deets.desc}",
style: TextStyle(
color: black,
fontSize: 19,
fontWeight: FontWeight.normal,
fontFamily: 'Roboto',
height: 1.8,
),
),
),
],
),
),
),
),
],
),
floatingActionButton: FloatingActionButton.extended(
onPressed: () {
// print(deets.latitude);
// print(deets.longitude);
Navigator.push(
context,
MaterialPageRoute(
builder: (context) => Gmaps(
latitude: deets.latitude, longitude: deets.longitude)));
},
label: const Text('Map'),
icon: const Icon(Icons.map),
),
bottomNavigationBar: Row(
crossAxisAlignment: CrossAxisAlignment.end,
mainAxisAlignment: MainAxisAlignment.spaceBetween,
children: <Widget>[
Expanded(child: ScheduleNotification(deets)),
Container(
width: 0.4,
height: 60,
color: Colors.white,
),
Expanded(child: Calendar(deets)),
],
),
);
}
}
//for Launching FB Url:
_launchURL() async {
const url = 'https://www.facebook.com/';
if (await canLaunch(url)) {
await launch(url);
} else {
throw 'Could not launch $url';
}
}
//For opening Clickable links from description text:
Future<void> _onOpen(LinkableElement link) async {
if (await canLaunch(link.url)) {
await launch(link.url);
} else {
throw 'Could not launch $link';
}
}