Fakultas Ilmu Komputer UI

Commit 183cd1a1 authored by Agnes Handoko's avatar Agnes Handoko
Browse files

[REFACTOR] finished filter feature and add switch case

parents 6c05d5b4 0be57530
Pipeline #38635 passed with stages
in 15 minutes and 56 seconds
import 'package:flutter/material.dart'; import 'package:flutter/material.dart';
final Color greenPrimary = Color(0xff3A903A); final Color greenPrimary = Color(0xff3A903A);
final Color greenPale = Color(0xff4FBA4F);
final Color redPrimary = Color(0xffC60000); final Color redPrimary = Color(0xffC60000);
final double superSmallSpace = 4.0;
final double smallSpace = 4.0; final double smallSpace = 4.0;
final double regularSpace = 8.0; final double regularSpace = 8.0;
final double regularBiggerSpace = 12.0;
final double doubleSpace = 16.0; final double doubleSpace = 16.0;
final double tripleSpace = 32.0; final double tripleSpace = 32.0;
final double spaceFourty = 45.0;
final double quartetSpace = 64.0; final double quartetSpace = 64.0;
final double spaceFourtyEight = 48.0; final double spaceFourtyEight = 48.0;
......
import 'package:flutter/material.dart'; import 'package:flutter/material.dart';
import 'package:ppl_disabilitas/app.dart'; //import 'package:ppl_disabilitas/app.dart';
import 'package:ppl_disabilitas/page/filter%20&%20fasilitas/filter.dart';
import 'flavor/flavor.dart'; import 'flavor/flavor.dart';
void main() { void main() {
ApiFlavor.flavor = BuildFlavor.production.toString(); ApiFlavor.flavor = BuildFlavor.production.toString();
runApp(BisaGo()); //runApp(BisaGo());
runApp(Filter());
} }
\ No newline at end of file
import 'package:flutter/foundation.dart';
import 'package:flutter/material.dart';
import 'package:ppl_disabilitas/page/filter%20&%20fasilitas/insideFilter.dart';
class Filter extends StatelessWidget {
// This widget is the root of your application.
@override
Widget build(BuildContext context) {
return MaterialApp(
title: 'Filter',
theme: ThemeData(
primarySwatch: Colors.green,
),
//home: new Icon(Icons.filter_list),
home: MyHomePage(title: 'Filter Informasi'),
);
}
}
class MyHomePage extends StatefulWidget {
MyHomePage({Key key, this.title}) : super(key: key);
// This widget is the home page of your application. It is stateful, meaning
// that it has a State object (defined below) that contains fields that affect
// how it looks.
// This class is the configuration for the state. It holds the values (in this
// case the title) provided by the parent (in this case the App widget) and
// used by the build method of the State. Fields in a Widget subclass are
// always marked "final".
final String title;
@override
_MyHomePageState createState() => _MyHomePageState();
}
class _MyHomePageState extends State<MyHomePage>
with SingleTickerProviderStateMixin {
AnimationController controller;
Animation<Offset> offset;
// final _controller = new PageController();
// static const _kDuration = const Duration(milliseconds: 300);
// static const _kCurve = Curves.ease;
// final _kArrowColor = Colors.black.withOpacity(0.8);
@override
void initState() {
super.initState();
controller =
AnimationController(vsync: this, duration: Duration(seconds: 1));
offset = Tween<Offset>(begin: Offset.zero, end: Offset(0.0, 1.0))
.animate(controller);
}
bool showUrutan = true;
GlobalKey<ScaffoldState> _scaffoldKey = GlobalKey<ScaffoldState>();
@override
Widget build(BuildContext context) {
return Scaffold(
key: _scaffoldKey,
appBar: AppBar(
key: Key("tambah informasi"),
title: Text(widget.title),
),
body: Align(
heightFactor: 150,
alignment: Alignment.bottomCenter,
child: SlideTransition(
position: offset,
child: Container(
// margin: EdgeInsets.all(25.0),
child: InsideFilter(),
),
),
),
floatingActionButton: FloatingActionButton(
key: Key("button"),
onPressed: () {
switch (controller.status) {
case AnimationStatus.completed:
controller.reverse();
break;
case AnimationStatus.dismissed:
controller.forward();
break;
default:
}
},
child: Icon(Icons.filter_list),
),
);
}
}
import 'package:flutter/material.dart';
import 'package:ppl_disabilitas/config/styles.dart';
class InsideFilter extends StatefulWidget {
@override
_InsideFilterState createState() => _InsideFilterState();
}
class _InsideFilterState extends State<InsideFilter>
with SingleTickerProviderStateMixin {
bool kursiRodaVal = false;
bool liftVal = false;
bool toiletDisabilitasVal = false;
bool tempatIbadahVal = false;
bool bidangMiringVal = false;
bool parkirUmumVal = false;
bool parkirDisabilitasVal = false;
bool komentarTerbaru = false;
bool komentarRatingTertinggi = false;
bool komentarTerpopuler = false;
bool showUrutan = true;
@override
Widget build(BuildContext context) {
return Container(
height: MediaQuery.of(context).size.height / 2,
decoration: BoxDecoration(
boxShadow: regularShadow,
borderRadius: BorderRadius.all(
Radius.circular(10) // <--- border radius here
),
color: Colors.white,
),
child: Container(
child: Column(
children: <Widget>[
Container(
padding: EdgeInsets.all(regularBiggerSpace),
child: Row(
mainAxisAlignment: MainAxisAlignment.spaceBetween,
children: <Widget>[
Row(
children: <Widget>[
Icon(Icons.filter_list),
Container(
margin: EdgeInsets.only(left: regularSpace),
child: Text(
'Filter Pencarian',
style: TextStyle(
color: Colors.black,
fontWeight: FontWeight.w800,
fontSize: 20.0),
),
),
],
),
Row(
children: <Widget>[
Text(
'BATAL',
style: TextStyle(
color: Colors.black,
fontWeight: FontWeight.w800,
fontSize: 17),
),
],
),
],
),
),
Container(
decoration: BoxDecoration(
border:
Border(top: BorderSide(color: greenPrimary, width: 1.5))),
),
Expanded(
child: Container(
child: Row(
children: <Widget>[
Expanded(
flex: 1,
child: Container(
decoration: BoxDecoration(
color: Colors.white,
),
child: ListView(
children: <Widget>[
InkWell(
child: Container(
decoration: BoxDecoration(
color: greenPale,
),
padding: EdgeInsets.only(
left: regularSpace,
right: regularSpace,
top: doubleSpace,
bottom: doubleSpace),
child: Text(
'Urutan',
style: TextStyle(
fontSize: 18,
color: Colors.white,
fontFamily: 'Muli',
),
),
),
splashColor: Colors.green[400],
highlightColor: Colors.green[400],
onTap: () => setState(() {
print('no');
showUrutan = true;
})),
Container(
decoration: BoxDecoration(
border: Border(
top:
BorderSide(color: greenPrimary, width: 1.5),
)),
),
InkWell(
child: Container(
decoration: BoxDecoration(
color: greenPale,
),
padding: EdgeInsets.only(
left: regularSpace,
right: regularSpace,
top: doubleSpace,
bottom: doubleSpace),
child: Text(
'Jenis Fasilitas',
style: TextStyle(
fontSize: 18,
color: Colors.white,
fontFamily: 'Muli',
),
),
),
splashColor: Colors.green[400],
highlightColor: Colors.green[400],
onTap: () => setState(() {
print("yes");
showUrutan = false;
})),
Container(
decoration: BoxDecoration(
border: Border(
top: BorderSide(
color: greenPrimary, width: 1.5))),
),
],
),
),
),
Expanded(
flex: 3,
child: Container(
decoration: BoxDecoration(
color: Colors.white,
border: Border(
left: BorderSide(color: greenPrimary, width: 1.5),
),
),
child: Stack(
children: <Widget>[
Opacity(
opacity: showUrutan ? 0 : 1,
child: ListView(
children: <Widget>[
Row(
crossAxisAlignment:
CrossAxisAlignment.center,
children: <Widget>[
Theme(
data: Theme.of(context).copyWith(
unselectedWidgetColor: greenPrimary,
),
child: Checkbox(
checkColor: Colors.red,
activeColor: Colors.amberAccent,
value: komentarTerbaru,
onChanged: (bool value) {
setState(() {
komentarTerbaru = value;
});
},
),
),
Text(
"Bidang Miring (Ramp)",
style: TextStyle(
color: Colors.black, fontSize: 18),
),
],
),
Row(
crossAxisAlignment:
CrossAxisAlignment.center,
children: <Widget>[
Theme(
data: Theme.of(context).copyWith(
unselectedWidgetColor: greenPrimary,
),
child: Checkbox(
checkColor: Colors.red,
activeColor: Colors.amberAccent,
value: komentarTerpopuler,
onChanged: (bool value) {
setState(() {
komentarTerpopuler = value;
});
},
),
),
Text(
"Komentar Terpopuler",
style: TextStyle(
color: Colors.black, fontSize: 18),
),
],
),
Container(
child: Row(
crossAxisAlignment:
CrossAxisAlignment.center,
children: <Widget>[
Theme(
data: Theme.of(context).copyWith(
unselectedWidgetColor: greenPrimary,
),
child: Checkbox(
checkColor: Colors.red,
activeColor: Colors.amberAccent,
value: komentarTerpopuler,
onChanged: (bool value) {
setState(() {
komentarTerpopuler = value;
});
},
),
),
Flexible(
child: Text(
"Komentar dengan Rating Tertinggi",
style: TextStyle(
color: Colors.black,
fontSize: 18),
),
),
],
),
),
],
),
),
Opacity(
opacity: showUrutan ? 1 : 0,
child: ListView(
children: <Widget>[
Row(
crossAxisAlignment:
CrossAxisAlignment.center,
children: <Widget>[
Theme(
data: Theme.of(context).copyWith(
unselectedWidgetColor: greenPrimary,
),
child: Checkbox(
checkColor: Colors.red,
activeColor: Colors.amberAccent,
value: kursiRodaVal,
onChanged: (bool value) {
setState(() {
kursiRodaVal = value;
});
},
),
),
Text(
"Kursi roda",
style: TextStyle(
color: Colors.black, fontSize: 18),
),
],
),
Row(
crossAxisAlignment:
CrossAxisAlignment.center,
children: <Widget>[
Theme(
data: Theme.of(context).copyWith(
unselectedWidgetColor: greenPrimary,
),
child: Checkbox(
checkColor: Colors.red,
activeColor: Colors.amberAccent,
value: liftVal,
onChanged: (bool value) {
setState(() {
liftVal = value;
});
},
),
),
Text(
"Lift",
style: TextStyle(
color: Colors.black, fontSize: 18),
),
],
),
Row(
crossAxisAlignment:
CrossAxisAlignment.center,
children: <Widget>[
Theme(
data: Theme.of(context).copyWith(
unselectedWidgetColor: greenPrimary,
),
child: Checkbox(
checkColor: Colors.red,
activeColor: Colors.amberAccent,
value: toiletDisabilitasVal,
onChanged: (bool value) {
setState(() {
toiletDisabilitasVal = value;
});
},
),
),
Text(
"Toilet Disabilitas",
style: TextStyle(
color: Colors.black, fontSize: 18),
),
],
),
Row(
crossAxisAlignment:
CrossAxisAlignment.center,
children: <Widget>[
Theme(
data: Theme.of(context).copyWith(
unselectedWidgetColor: greenPrimary,
),
child: Checkbox(
checkColor: Colors.red,
activeColor: Colors.amberAccent,
value: tempatIbadahVal,
onChanged: (bool value) {
setState(() {
tempatIbadahVal = value;
});
},
),
),
Text(
"Tempat Ibadah",
style: TextStyle(
color: Colors.black, fontSize: 18),
),
],
),
Row(
crossAxisAlignment:
CrossAxisAlignment.center,
children: <Widget>[
Theme(
data: Theme.of(context).copyWith(
unselectedWidgetColor: greenPrimary,
),
child: Checkbox(
checkColor: Colors.red,
activeColor: Colors.amberAccent,
value: bidangMiringVal,
onChanged: (bool value) {
setState(() {
bidangMiringVal = value;
});
},
),
),
Text(
"Bidang Miring (Ramp)",
style: TextStyle(
color: Colors.black, fontSize: 18),
),
],
),
Row(
crossAxisAlignment:
CrossAxisAlignment.center,
children: <Widget>[
Theme(
data: Theme.of(context).copyWith(
unselectedWidgetColor: greenPrimary,
),
child: Checkbox(
checkColor: Colors.red,
activeColor: Colors.amberAccent,
value: parkirUmumVal,
onChanged: (bool value) {
setState(() {
parkirUmumVal = value;
});
},
),
),
Text(
"Parkir Umum",
style: TextStyle(
color: Colors.black, fontSize: 18),
),
],
),
Row(
crossAxisAlignment:
CrossAxisAlignment.center,
children: <Widget>[
Theme(
data: Theme.of(context).copyWith(
unselectedWidgetColor: greenPrimary,
),
child: Checkbox(
checkColor: Colors.red,
activeColor: Colors.amberAccent,
value: parkirDisabilitasVal,
onChanged: (bool value) {
setState(() {
parkirDisabilitasVal = value;
});
},
),
),
Text(
"Parkir Disabilitas",
style: TextStyle(
color: Colors.black, fontSize: 18),
),
//Container(height: 1.0,),
],
),
],
),
),
],
),
),
),
],
),