Skip to content

Commit

Permalink
removed bus list
Browse files Browse the repository at this point in the history
  • Loading branch information
Hareesh-Nandigrama committed Feb 22, 2024
1 parent e656e31 commit 0d1fc03
Show file tree
Hide file tree
Showing 2 changed files with 86 additions and 72 deletions.
115 changes: 65 additions & 50 deletions lib/widgets/travel/stops_bus_details.dart
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,6 @@ import 'package:onestop_dev/globals/my_colors.dart';
import 'package:onestop_dev/globals/my_fonts.dart';
import 'package:onestop_dev/stores/travel_store.dart';
import 'package:onestop_dev/widgets/travel/bus_details.dart';
import 'package:onestop_dev/widgets/travel/stops_list.dart';
import 'package:onestop_dev/widgets/travel/tracking_dailog.dart';
import 'package:onestop_dev/widgets/travel/travel_drop_down.dart';
import 'package:provider/provider.dart';
Expand Down Expand Up @@ -36,7 +35,8 @@ class _StopsBusDetailsState extends State<StopsBusDetails> {
children: [
TextButton(
onPressed: () {
travelStore.selectStopButton();
showDialog(
context: context, builder: (_) => const TrackingDailog());
},
child: ClipRRect(
borderRadius: const BorderRadius.all(
Expand All @@ -45,64 +45,79 @@ class _StopsBusDetailsState extends State<StopsBusDetails> {
child: Container(
height: 32,
width: 83,
color: (!travelStore.isBusSelected) ? lBlue2 : kGrey2,
color: lBlue2,
child: Center(
child: Text("Stops",
style: (!travelStore.isBusSelected)
? MyFonts.w500.setColor(kBlueGrey)
: MyFonts.w500.setColor(kWhite)),
),
),
),
),
TextButton(
onPressed: () {
travelStore.selectBusButton();
},
child: ClipRRect(
borderRadius: const BorderRadius.all(
Radius.circular(40),
),
child: Container(
height: 32,
width: 83,
color: (travelStore.isBusSelected) ? lBlue2 : kGrey2,
child: Center(
child: Text(
"Bus",
style: (travelStore.isBusSelected)
? MyFonts.w500.setColor(kBlueGrey)
: MyFonts.w500.setColor(kWhite),
),
child: Text(" Track Bus ",
style: MyFonts.w500.setColor(kBlueGrey)),
),
),
),
),
// GestureDetector(
// onTap: () {
// showDialog(
// context: context, builder: (_) => const TrackingDailog());
// },
// child: Text(
// "Track Bus",
// style: MyFonts.w500.setColor(kWhite),
// ),
// ),
// TextButton(
// onPressed: () {
// travelStore.selectStopButton();
// },
// child: ClipRRect(
// borderRadius: const BorderRadius.all(
// Radius.circular(40),
// ),
// child: Container(
// height: 32,
// width: 83,
// color: (!travelStore.isBusSelected) ? lBlue2 : kGrey2,
// child: Center(
// child: Text("Stops",
// style: (!travelStore.isBusSelected)
// ? MyFonts.w500.setColor(kBlueGrey)
// : MyFonts.w500.setColor(kWhite)),
// ),
// ),
// ),
// ),
// TextButton(
// onPressed: () {
// travelStore.selectBusButton();
// },
// child: ClipRRect(
// borderRadius: const BorderRadius.all(
// Radius.circular(40),
// ),
// child: Container(
// height: 32,
// width: 83,
// color: (travelStore.isBusSelected) ? lBlue2 : kGrey2,
// child: Center(
// child: Text(
// "Bus",
// style: (travelStore.isBusSelected)
// ? MyFonts.w500.setColor(kBlueGrey)
// : MyFonts.w500.setColor(kWhite),
// ),
// ),
// ),
// ),
// ),
Expanded(
child: Container(),
),
travelStore.isBusSelected
? TravelDropDown(
value: travelStore.busDayType,
onChange: travelStore.setBusDayString,
items: const ['Weekdays', 'Weekends'],
)
: GestureDetector(
onTap: () {
showDialog(
context: context,
builder: (_) => const TrackingDailog());
},
child: Text(
"Track Bus",
style: MyFonts.w500.setColor(kWhite),
),
)
TravelDropDown(
value: travelStore.busDayType,
onChange: travelStore.setBusDayString,
items: const ['Weekdays', 'Weekends'],
)
],
),
!travelStore.isBusSelected
? const BusStopList()
: BusDetails(index: travelStore.busDayTypeIndex)
BusDetails(index: travelStore.busDayTypeIndex)
],
);
});
Expand Down
43 changes: 21 additions & 22 deletions lib/widgets/travel/stops_list.dart
Original file line number Diff line number Diff line change
Expand Up @@ -26,27 +26,25 @@ class BusStopList extends StatelessWidget {
var mapStore = context.read<MapBoxStore>();
var travelStore = context.read<TravelStore>();
return FutureBuilder<List<TravelTiming>>(
// future: APIService().getBusTiming(),
future: travelStore.getBusTimings(),
builder: (context, snapshot) {
if (snapshot.hasData) {
List<TravelTiming>? busTime = snapshot.data;
if(busTime!.isEmpty)
{
return Container();
}
List<DateTime> weekdaysTimes=[];
List<DateTime> weekendTimes=[];
for(var xyz in busTime){
int n=xyz.weekdays.fromCampus.length;
for(int i=0;i<n;i++){
if (busTime!.isEmpty) {
return Container();
}
List<DateTime> weekdaysTimes = [];
List<DateTime> weekendTimes = [];
for (var xyz in busTime) {
int n = xyz.weekdays.fromCampus.length;
for (int i = 0; i < n; i++) {
weekdaysTimes.add(xyz.weekdays.fromCampus[i]);
}
}
weekdaysTimes.sort((a, b) => a.compareTo(b));
for(var xyz in busTime){
int n=xyz.weekend.fromCampus.length;
for(int i=0;i<n;i++){
for (var xyz in busTime) {
int n = xyz.weekend.fromCampus.length;
for (int i = 0; i < n; i++) {
weekendTimes.add(xyz.weekend.fromCampus[i]);
}
}
Expand All @@ -59,9 +57,9 @@ class BusStopList extends StatelessWidget {
mapStore.zoomTwoMarkers(
LatLng(
mapStore.allLocationData[
mapStore.selectedCarouselIndex]['lat'],
mapStore.selectedCarouselIndex]['lat'],
mapStore.allLocationData[
mapStore.selectedCarouselIndex]['long']),
mapStore.selectedCarouselIndex]['long']),
LatLng(mapStore.userlat, mapStore.userlong),
100.0);
},
Expand All @@ -71,7 +69,7 @@ class BusStopList extends StatelessWidget {
decoration: BoxDecoration(
color: kTileBackground,
borderRadius:
const BorderRadius.all(Radius.circular(20)),
const BorderRadius.all(Radius.circular(20)),
border: Border.all(
color: (mapStore.selectedCarouselIndex == index)
? lBlue5
Expand Down Expand Up @@ -101,13 +99,14 @@ class BusStopList extends StatelessWidget {
trailing: Text(
(getFormattedDay() == 'Fri')
? nextTime(weekendTimes,
firstTime: weekendTimes[0].toString())
firstTime: weekendTimes[0].toString())
: (getFormattedDay() == 'Sun')
? nextTime(weekendTimes,
firstTime: weekdaysTimes[0].toString())
: (getFormattedDay() == 'Sat')
? nextTime(weekendTimes)
: nextTime(weekdaysTimes),
? nextTime(weekendTimes,
firstTime:
weekdaysTimes[0].toString())
: (getFormattedDay() == 'Sat')
? nextTime(weekendTimes)
: nextTime(weekdaysTimes),
style: MyFonts.w500.setColor(lBlue2),
)),
);
Expand Down

0 comments on commit 0d1fc03

Please sign in to comment.