Skip to content

Commit

Permalink
refactored bottom sheet and area cards, now usable components
Browse files Browse the repository at this point in the history
  • Loading branch information
JohnnyNguyen01 committed Aug 16, 2020
1 parent 1b5bb94 commit 29d7748
Show file tree
Hide file tree
Showing 4 changed files with 148 additions and 103 deletions.
75 changes: 75 additions & 0 deletions lib/components/area_update_card.dart
Original file line number Diff line number Diff line change
@@ -0,0 +1,75 @@
import 'package:flutter/material.dart';
import 'package:font_awesome_flutter/font_awesome_flutter.dart';

class AreaUpdateCard extends StatelessWidget {
/*
Original values
color: Green.shade500
textOne: RFS has successfuly responded and
textTwo: put out the small fire at 5:00pm
icon: FontAwesomeIcons.checkCircle
*/

String title;
String textOne;
String textTwo;
Color color;
IconData icon;

AreaUpdateCard({
this.title,
this.textOne,
this.textTwo,
this.color,
this.icon,
});

@override
Widget build(BuildContext context) {
return Card(
child: ClipRRect(
borderRadius: BorderRadius.circular(12),
child: Container(
width: 320,
height: 80,
color: color,
child: Row(
children: <Widget>[
Container(
margin: EdgeInsets.only(left: 8),
child: FaIcon(
icon,
color: Colors.white,
size: 40,
),
),
Container(
margin: EdgeInsets.only(left: 8),
child: Column(
mainAxisAlignment: MainAxisAlignment.start,
children: <Widget>[
Text(
title,
style: TextStyle(
fontSize: 18,
fontWeight: FontWeight.w600,
color: Colors.white),
),
Text(
textOne,
style: TextStyle(color: Colors.white),
),
Text(
textTwo,
style: TextStyle(color: Colors.white),
),
],
),
),
],
),
),
),
);
}
}
146 changes: 44 additions & 102 deletions lib/components/bottom_sheet.dart
Original file line number Diff line number Diff line change
@@ -1,10 +1,29 @@
import 'package:flutter/material.dart';
import 'package:font_awesome_flutter/font_awesome_flutter.dart';
import 'area_update_card.dart';

//initial values
// "https://www.nationalparks.nsw.gov.au/-/media/npws/images/parks/gundabooka-national-park/little-mountain-walking-track/little-mountain-track-01.jpg"
// Sydney
// 124
// none

class CustomBottomSheet extends StatelessWidget {
const CustomBottomSheet({
Key key,
}) : super(key: key);
String location;
String imageURL;
bool isSafe;
String rfsResponse;
String reports;
List<Widget> areaUpdateCardsList;

CustomBottomSheet({
this.imageURL,
this.reports,
this.location,
this.isSafe,
this.rfsResponse,
this.areaUpdateCardsList,
});

@override
Widget build(BuildContext context) {
Expand All @@ -16,15 +35,14 @@ class CustomBottomSheet extends StatelessWidget {
children: <Widget>[
ClipRRect(
borderRadius: BorderRadius.circular(12.0),
child: Image.network(
"https://www.nationalparks.nsw.gov.au/-/media/npws/images/parks/gundabooka-national-park/little-mountain-walking-track/little-mountain-track-01.jpg"),
child: Image.network(imageURL),
),
Container(
margin: EdgeInsets.only(left: 12),
child: Column(
children: <Widget>[
Text(
"SYDNEY",
location,
style: TextStyle(fontSize: 25, fontWeight: FontWeight.bold),
),
SizedBox(height: 12),
Expand All @@ -38,9 +56,10 @@ class CustomBottomSheet extends StatelessWidget {
),
),
Text(
"SAFE",
isSafe ? "SAFE" : "DANGER",
style: TextStyle(
fontSize: 20, color: Colors.green.shade500),
fontSize: 20,
color: isSafe ? Colors.green.shade500 : Colors.red),
),
],
),
Expand All @@ -55,7 +74,7 @@ class CustomBottomSheet extends StatelessWidget {
),
),
Text(
"124",
reports,
style: TextStyle(
fontSize: 20,
),
Expand Down Expand Up @@ -84,26 +103,22 @@ class CustomBottomSheet extends StatelessWidget {
Column(
children: <Widget>[
Text("Latest Area Updates"),
ClipRRect(
borderRadius: BorderRadius.circular(12),
child: AreaUpdateCard(
title: "Area now declared SAFE",
color: Colors.green.shade500,
textOne: "RFS has successfuly responded and",
textTwo: "put out the small fire at 5:00pm",
icon: FontAwesomeIcons.checkCircle,
),
),
SizedBox(
height: 15,
),
AreaUpdateCard(
title: "Area now declared DANGEROUS",
textOne: "RFS Alerted to the scene",
textTwo: "mild fire ",
icon: FontAwesomeIcons.bell,
color: Colors.red.shade700,
),
SizedBox(height: 15),
ListView.builder(
physics: NeverScrollableScrollPhysics(),
shrinkWrap: true,
itemCount: areaUpdateCardsList.length,
itemBuilder: (context, index) {
return (Column(
children: <Widget>[
areaUpdateCardsList[index],
SizedBox(
height: 12,
)
],
));
},
)
],
),
],
Expand All @@ -115,76 +130,3 @@ class CustomBottomSheet extends StatelessWidget {
);
}
}

class AreaUpdateCard extends StatelessWidget {
/*
Original values
color: Green.shade500
textOne: RFS has successfuly responded and
textTwo: put out the small fire at 5:00pm
icon: FontAwesomeIcons.checkCircle
*/

String title;
String textOne;
String textTwo;
Color color;
IconData icon;

AreaUpdateCard({
this.title,
this.textOne,
this.textTwo,
this.color,
this.icon,
});

@override
Widget build(BuildContext context) {
return Card(
child: ClipRRect(
borderRadius: BorderRadius.circular(12),
child: Container(
width: 320,
height: 80,
color: color,
child: Row(
children: <Widget>[
Container(
margin: EdgeInsets.only(left: 8),
child: FaIcon(
icon,
color: Colors.white,
size: 40,
),
),
Container(
margin: EdgeInsets.only(left: 8),
child: Column(
mainAxisAlignment: MainAxisAlignment.start,
children: <Widget>[
Text(
title,
style: TextStyle(
fontSize: 18,
fontWeight: FontWeight.w600,
color: Colors.white),
),
Text(
textOne,
style: TextStyle(color: Colors.white),
),
Text(
textTwo,
style: TextStyle(color: Colors.white),
),
],
),
),
],
),
),
),
);
}
}
20 changes: 20 additions & 0 deletions lib/data/area_update_card_lists.dart
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
import 'package:flutter/material.dart';
import 'package:font_awesome_flutter/font_awesome_flutter.dart';
import 'package:signal_flutter_v2/components/area_update_card.dart';

final sydney = [
AreaUpdateCard(
title: "Area now declared SAFE",
color: Colors.green.shade500,
textOne: "RFS has successfuly responded and",
textTwo: "put out the small fire at 5:00pm",
icon: FontAwesomeIcons.checkCircle,
),
AreaUpdateCard(
title: "Area now declared DANGEROUS",
textOne: "RFS Alerted to the scene",
textTwo: "mild fire ",
icon: FontAwesomeIcons.bell,
color: Colors.red.shade700,
),
];
10 changes: 9 additions & 1 deletion lib/screens/home_screen.dart
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ import 'package:google_maps_flutter/google_maps_flutter.dart';
import 'package:modal_bottom_sheet/modal_bottom_sheet.dart';
import 'package:font_awesome_flutter/font_awesome_flutter.dart';
import 'package:signal_flutter_v2/components/bottom_sheet.dart';
import 'package:signal_flutter_v2/data/area_update_card_lists.dart';

//REMOVE THIS GOOGLE_MAPS_API_KEY = 'AIzaSyAr31utYalU_q4_Lh1GtqZrCDgg0VBlcHI'

Expand Down Expand Up @@ -43,7 +44,14 @@ class _HomeScreenState extends State<HomeScreen> {
return Opacity(
opacity: 0.8,
child: Scaffold(
body: CustomBottomSheet(),
body: CustomBottomSheet(
location: "Sydney",
reports: "124",
isSafe: true,
rfsResponse: "none",
areaUpdateCardsList: sydney,
imageURL:
"https://www.nationalparks.nsw.gov.au/-/media/npws/images/parks/gundabooka-national-park/little-mountain-walking-track/little-mountain-track-01.jpg"),
),
);
});
Expand Down

0 comments on commit 29d7748

Please sign in to comment.