Skip to content

Commit

Permalink
feat: can see speaker flights (design rework is needed) #298
Browse files Browse the repository at this point in the history
  • Loading branch information
bvlourenco committed Nov 19, 2022
1 parent 83e0b29 commit 07e1446
Show file tree
Hide file tree
Showing 5 changed files with 164 additions and 51 deletions.
2 changes: 1 addition & 1 deletion backend/src/router/thread_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -548,7 +548,7 @@ func TestUpdateThread(t *testing.T) {
assert.NilError(t, err)

data := mongodb.UpdateThreadData{
Meeting: newMeeting.ID,
Meeting: &newMeeting.ID,
Kind: newKind,
}

Expand Down
54 changes: 4 additions & 50 deletions frontend/lib/routes/speaker/SpeakerScreen.dart
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ import 'package:frontend/components/threads/participations/communicationsList.da
import 'package:frontend/components/threads/threadCard/threadCard.dart';
import 'package:frontend/models/flightInfo.dart';
import 'package:frontend/routes/speaker/AddFlightInfoForm.dart';
import 'package:frontend/routes/speaker/flights/flightInfoScreen.dart';
import 'package:frontend/routes/speaker/speakerNotifier.dart';
import 'package:frontend/components/status.dart';
import 'package:frontend/main.dart';
Expand Down Expand Up @@ -106,8 +107,9 @@ class _SpeakerScreenState extends State<SpeakerScreen>
speaker: widget.speaker,
),
FlightInfoScreen(
lastParticipation: widget.speaker.participations![
widget.speaker.participations!.length - 1]),
participations: widget.speaker.participations ?? [],
id: widget.speaker.id,
small: small),
ParticipationList(
speaker: widget.speaker,
onParticipationChanged: (Map<String, dynamic> body) async {
Expand Down Expand Up @@ -512,51 +514,3 @@ class DetailsScreen extends StatelessWidget {
);
}
}

class FlightInfoScreen extends StatelessWidget {
final SpeakerParticipation lastParticipation;
const FlightInfoScreen({Key? key, required this.lastParticipation})
: super(key: key);

@override
Widget build(BuildContext context) {
return Padding(
padding: const EdgeInsets.all(8.0),
child: FutureBuilder(
future: lastParticipation.flights,
builder: (context, snapshot) {
if (snapshot.hasError) {
return Text('Error');
}
if (snapshot.connectionState == ConnectionState.done) {
List<FlightInfo>? flightInfos = snapshot.data as List<FlightInfo>?;
if (flightInfos == null) {
flightInfos = [];
}
flightInfos.sort((a, b) => b.inbound.compareTo(a.inbound));
return Column(children: [
Align(
alignment: Alignment.centerLeft,
child: Padding(
padding: const EdgeInsets.all(8.0),
child: Text('SINFO ${lastParticipation.event}'),
),
),
Divider(),
...flightInfos
.map(
(flightInfo) => Padding(
padding: const EdgeInsets.all(8.0),
child: Text("In Progress - " + flightInfo.notes),
),
)
.toList(),
]);
} else {
return Center(child: CircularProgressIndicator());
}
},
),
);
}
}
59 changes: 59 additions & 0 deletions frontend/lib/routes/speaker/flights/flightCard.dart
Original file line number Diff line number Diff line change
@@ -0,0 +1,59 @@
import 'package:flutter/material.dart';
import 'package:frontend/components/threads/threadCard/threadCardBody.dart';
import 'package:frontend/components/threads/threadCard/threadCardHeader.dart';
import 'package:frontend/models/flightInfo.dart';
import 'package:frontend/models/post.dart';
import 'package:intl/intl.dart';
import 'package:shimmer/shimmer.dart';

class FlightCard extends StatefulWidget {
FlightInfo flight;
final String id;
final bool small;
FlightCard(
{Key? key, required this.flight, required this.small, required this.id})
: super(key: key);

@override
_FlightCardState createState() => _FlightCardState();
}

class _FlightCardState extends State<FlightCard>
with AutomaticKeepAliveClientMixin {
bool get wantKeepAlive => true;

Future<void> flightChangedCallback(BuildContext context,
{FlightInfo? flight}) async {
setState(() {
widget.flight = flight!;
});
}

@override
Widget build(BuildContext context) {
super.build(context);
return Padding(
padding: const EdgeInsets.all(8),
child: Container(
margin: EdgeInsets.fromLTRB(0, 20, 0, 0),
padding: EdgeInsets.fromLTRB(17, 15, 17, 15),
decoration: BoxDecoration(
color: Theme.of(context).cardColor,
borderRadius: BorderRadius.circular(5)),
child: Column(
crossAxisAlignment: CrossAxisAlignment.start,
children: [
Text("Departure: " + widget.flight.from),
Text("Departure date: " + DateFormat('yyyy-MM-dd HH:mm').format(widget.flight.outbound)),
Text("Arrival: " + widget.flight.to),
Text("Arrival date: " + DateFormat('yyyy-MM-dd HH:mm').format(widget.flight.inbound)),
Text("Flight link: " + widget.flight.link),
Text("Flight bought? " + widget.flight.bought.toString()),
Text("Flight cost: " + widget.flight.cost.toString()),
Text("Flight notes:" + widget.flight.notes),
],
),
),
);
}
}
37 changes: 37 additions & 0 deletions frontend/lib/routes/speaker/flights/flightInfoScreen.dart
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
import 'package:flutter/material.dart';
import 'package:frontend/models/participation.dart';
import 'package:frontend/routes/speaker/flights/participationFlightsWidget.dart';

class FlightInfoScreen extends StatelessWidget {
final List<SpeakerParticipation> participations;
final String id;
final bool small;
const FlightInfoScreen(
{Key? key,
required this.participations,
required this.small,
required this.id})
: super(key: key);

@override
Widget build(BuildContext context) {
return LayoutBuilder(builder: (context, constraints) {
return Padding(
padding: const EdgeInsets.fromLTRB(0, 0, 0, 20),
child: ListView(
controller: ScrollController(),
children: participations.reversed
.where((element) =>
element.flightsId != null && element.flightsId!.length != 0)
.map(
(participation) => ParticipationFlightsWidget(
participation: participation,
id: id,
small: small,
),
)
.toList()),
);
});
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,63 @@
import 'package:flutter/material.dart';
import 'package:frontend/models/flightInfo.dart';
import 'package:frontend/models/participation.dart';
import 'package:frontend/routes/speaker/flights/flightCard.dart';

class ParticipationFlightsWidget extends StatelessWidget {
final SpeakerParticipation participation;
final String id;
final bool small;

ParticipationFlightsWidget(
{Key? key,
required this.participation,
required this.small,
required this.id})
: super(key: key);

@override
Widget build(BuildContext context) {
return Padding(
padding: const EdgeInsets.all(8.0),
child: FutureBuilder(
future: participation.flights,
builder: (context, snapshot) {
if (snapshot.hasError) {
return Text('Error');
}
if (snapshot.connectionState == ConnectionState.done) {
List<FlightInfo>? flightInfos = snapshot.data as List<FlightInfo>?;
if (flightInfos == null) {
flightInfos = [];
}
flightInfos.sort((a, b) => b.outbound.compareTo(a.outbound));
return Column(children: [
Align(
alignment: Alignment.centerLeft,
child: Padding(
padding: const EdgeInsets.all(8.0),
child: Text('SINFO ${participation.event}'),
),
),
Divider(),
...flightInfos
.map(
(flightInfo) => Padding(
padding: const EdgeInsets.all(8.0),
child: FlightCard(
flight: flightInfo,
id: id,
small: small,
),
),
)
.toList(),
]);
} else {
return Center(child: CircularProgressIndicator());
}
},
),
);
}
}

0 comments on commit 07e1446

Please sign in to comment.