shuttleList method

  1. @override
dynamic shuttleList (
  1. int idx,
  2. Function _containsFilter,
  3. Function _jumpMap
)

Builds the shuttlelist widget which contains all the stops and useful user information like the next arrival.

Implementation

@override
Widget shuttleList(int idx, Function _containsFilter, Function _jumpMap) {
  return ScrollablePositionedList.builder(
    itemCount: shuttleStopLists[idx].length,
    itemBuilder: (context, index) {
      var curStopList = shuttleStopLists[idx];
      return CustomExpansionTile(
        title: Text(curStopList[index % curStopList.length][0]),
        subtitle: Text('Next Arrival: ' +
            shuttleTimeLists[idx][_getTimeIndex(shuttleTimeLists[idx])]),
        leading: CustomPaint(
            painter: FillPainter(
                circleColor: Theme.of(context).buttonColor,
                lineColor: Theme.of(context).primaryColorLight,
                first: index == 0,
                last: index == curStopList.length - 1),
            child: Container(
              height: 50,
              width: 45,
            )),
        trailing:
            //toggle()
            isExpandedList[index % curStopList.length]
                ? Text('Hide Arrivals -')
                : Text('Show Arrivals +'),
        onExpansionChanged: (value) {
          setState(() {
            isExpandedList[index % curStopList.length] = value;
          });
        },
        children: [
          CustomPaint(
            painter: StrokePainter(
              circleColor: Theme.of(context).buttonColor,
              lineColor: Theme.of(context).primaryColorLight,
              last: index == curStopList.length - 1,
            ),
            child: ListTile(
                contentPadding: EdgeInsets.zero,
                leading: Container(
                  margin: const EdgeInsets.only(left: 34.5),
                  constraints: BoxConstraints.expand(width: 8),
                ),
                title: Container(
                  // height: 100.0,
                  // margin: const EdgeInsets.only(left: 0),
                  child: RefreshIndicator(
                    onRefresh: () =>
                        Future.delayed(const Duration(seconds: 1), () => "1"),
                    displacement: 1,
                    child: ListView.builder(
                      shrinkWrap: true,
                      itemCount: 5,
                      itemExtent: 50,
                      itemBuilder: (BuildContext context, int timeIndex) {
                        return ListTile(
                          dense: true,
                          leading: Icon(Icons.access_time, size: 20),
                          title: Text(
                            '${shuttleTimeLists[idx][timeIndex]}',
                            style: TextStyle(fontSize: 15),
                          ),
                          subtitle: Text('In 11 minutes'),
                          trailing: PopupMenuButton<String>(
                              onSelected: (String selected) {
                                if (selected == choices[0]) {
                                  _jumpMap(
                                      double.parse(
                                          shuttleStopLists[idx][index][1]),
                                      double.parse(
                                          shuttleStopLists[idx][index][2]));
                                }
                                if (selected == choices[2]) {
                                  scheduleAlarm();
                                }
                              },
                              itemBuilder: (BuildContext context) => choices
                                  .map((choice) => PopupMenuItem<String>(
                                      value: choice, child: Text(choice)))
                                  .toList()),
                        );
                      },
                    ),
                  ),
                )),
          ),
        ],
      );
    },
  );
}