-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
5fc0081
commit 5691613
Showing
16 changed files
with
398 additions
and
137 deletions.
There are no files selected for viewing
Large diffs are not rendered by default.
Oops, something went wrong.
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,122 +1,69 @@ | ||
import 'package:cloud_firestore/cloud_firestore.dart'; | ||
import 'package:flutter/cupertino.dart'; | ||
import 'package:flutter/material.dart'; | ||
import 'package:carousel_slider/carousel_slider.dart'; | ||
import 'package:url_launcher/url_launcher.dart'; | ||
import 'home/carousel_slider.dart'; | ||
import 'home/action_chip.dart'; | ||
import 'home/featured_notes.dart'; | ||
import 'home/pinned_notes.dart'; | ||
|
||
class Home extends StatelessWidget { | ||
@override | ||
Widget build(BuildContext context) { | ||
Color carouselSliderFill = Colors.grey[300]; | ||
Color actionChipBackground = Colors.grey[300]; | ||
var brightness = MediaQuery.of(context).platformBrightness; | ||
bool darkModeOn = brightness == Brightness.dark; | ||
if (darkModeOn == true) { | ||
carouselSliderFill = Colors.grey[900]; | ||
actionChipBackground = Colors.grey[900]; | ||
} | ||
return Scaffold( | ||
body: ListView( | ||
children: <Widget>[ | ||
Column( | ||
children: [ | ||
StreamBuilder( | ||
stream: FirebaseFirestore.instance | ||
.collection('CarouselSlider') | ||
.snapshots(), | ||
builder: (context, snapshot) { | ||
if (snapshot.connectionState == ConnectionState.waiting) { | ||
return Center( | ||
child: Text("Loading"), | ||
); | ||
} else if (!snapshot.hasData) { | ||
return Center( | ||
child: Text("Couldn't connect to the server."), | ||
); | ||
} else { | ||
return Container( | ||
color: carouselSliderFill, | ||
padding: EdgeInsets.all(6.0), | ||
child: CarouselSlider.builder( | ||
options: CarouselOptions( | ||
height: 200.0, | ||
viewportFraction: 1.0, | ||
autoPlay: true, | ||
autoPlayInterval: Duration(seconds: 30), | ||
enableInfiniteScroll: false, | ||
), | ||
itemCount: snapshot.data.docs.length, | ||
itemBuilder: (context, position) { | ||
DocumentSnapshot images = | ||
snapshot.data.docs[position]; | ||
return Container( | ||
child: GestureDetector( | ||
onTap: () => | ||
_launchURL(images.data()['ExternalURL']), | ||
child: Image.network( | ||
images.data()['ImagePath'], | ||
fit: BoxFit.fill, | ||
), | ||
), | ||
); | ||
}), | ||
); | ||
} | ||
}), | ||
Container( | ||
margin: EdgeInsets.all(8.0), | ||
height: 50, | ||
child: StreamBuilder( | ||
stream: FirebaseFirestore.instance | ||
.collection('ActionChips') | ||
.snapshots(), | ||
builder: (context, snapshot) { | ||
if (snapshot.connectionState == ConnectionState.waiting) { | ||
return Center( | ||
child: Text("Loading."), | ||
); | ||
} else if (!snapshot.hasData) { | ||
return Center( | ||
child: Text("Couldn't connect to the server."), | ||
); | ||
} else { | ||
return new Expanded( | ||
child: ListView.builder( | ||
shrinkWrap: true, | ||
physics: ClampingScrollPhysics(), | ||
scrollDirection: Axis.horizontal, | ||
itemCount: snapshot.data.documents.length, | ||
itemBuilder: (context, position) { | ||
DocumentSnapshot chips = | ||
snapshot.data.docs[position]; | ||
return Padding( | ||
padding: const EdgeInsets.all(8.0), | ||
child: Container( | ||
child: ActionChip( | ||
backgroundColor: actionChipBackground, | ||
label: Text(chips.data()['Label']), | ||
onPressed: () { | ||
print("Chip Pressed"); | ||
}), | ||
), | ||
); | ||
}), | ||
); | ||
} | ||
}), | ||
// CarouselSlider | ||
CarouselSliderBuilder(), | ||
|
||
// ActionChip | ||
ActionChipBuilder(), | ||
|
||
// FeaturedNotes | ||
Padding( | ||
padding: const EdgeInsets.all(10.0), | ||
child: Row( | ||
mainAxisAlignment: MainAxisAlignment.spaceBetween, | ||
children: [ | ||
Text("Featured notes", | ||
style: TextStyle( | ||
fontSize: 18.0, fontWeight: FontWeight.w500)), | ||
GestureDetector( | ||
// onTap: () =>, | ||
child: Text("See more", | ||
style: TextStyle( | ||
fontSize: 14.0, | ||
fontWeight: FontWeight.w400, | ||
color: Colors.deepOrangeAccent))) | ||
], | ||
), | ||
), | ||
FeaturedNotesBuilder(), | ||
|
||
// PinnedNotes | ||
Padding( | ||
padding: const EdgeInsets.all(10.0), | ||
child: Row( | ||
mainAxisAlignment: MainAxisAlignment.spaceBetween, | ||
children: [ | ||
Text("Pinned notes", | ||
style: TextStyle( | ||
fontSize: 18.0, fontWeight: FontWeight.w500)), | ||
GestureDetector( | ||
// onTap: () =>, | ||
child: Text("See more", | ||
style: TextStyle( | ||
fontSize: 14.0, | ||
fontWeight: FontWeight.w400, | ||
color: Colors.deepOrangeAccent))) | ||
], | ||
), | ||
), | ||
PinnedNotesBuilder(), | ||
], | ||
), | ||
], | ||
), | ||
); | ||
} | ||
} | ||
|
||
_launchURL(String url) async { | ||
if (await canLaunch(url)) { | ||
await launch(url); | ||
} else { | ||
throw 'Could not launch $url'; | ||
} | ||
} |
Oops, something went wrong.