-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat: can see speaker flights (design rework is needed) #298
- Loading branch information
1 parent
83e0b29
commit 07e1446
Showing
5 changed files
with
164 additions
and
51 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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), | ||
], | ||
), | ||
), | ||
); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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()), | ||
); | ||
}); | ||
} | ||
} |
63 changes: 63 additions & 0 deletions
63
frontend/lib/routes/speaker/flights/participationFlightsWidget.dart
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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()); | ||
} | ||
}, | ||
), | ||
); | ||
} | ||
} |