Skip to content

Commit

Permalink
fix: loading from cache in some cases #290
Browse files Browse the repository at this point in the history
  • Loading branch information
bvlourenco committed Dec 1, 2022
1 parent 8221561 commit ced347f
Show file tree
Hide file tree
Showing 27 changed files with 411 additions and 405 deletions.
4 changes: 0 additions & 4 deletions frontend/lib/components/memberPartCard.dart
Original file line number Diff line number Diff line change
@@ -1,8 +1,4 @@
import 'dart:html';

import 'package:flutter/material.dart';
import 'package:frontend/services/authService.dart';
import 'package:provider/provider.dart';

final Map<String, String> roles = {
"MEMBER": "Member",
Expand Down
1 change: 0 additions & 1 deletion frontend/lib/components/router.dart
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,6 @@ import 'package:frontend/routes/company/CompanyListWidget.dart';
import 'package:frontend/routes/meeting/AddMeetingForm.dart';
import 'package:frontend/routes/member/AddMemberForm.dart';
import 'package:frontend/routes/member/MemberListWidget.dart';
import 'package:frontend/routes/speaker/flights/AddFlightInfoForm.dart';
import 'package:frontend/routes/speaker/SpeakerListWidget.dart';
import 'package:frontend/routes/speaker/AddSpeakerForm.dart';
import 'package:frontend/routes/teams/AddTeamMemberForm.dart';
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ class CommunicationsList extends StatefulWidget {
}

class _CommunicationsListState extends State<CommunicationsList>
with SingleTickerProviderStateMixin {
with SingleTickerProviderStateMixin, AutomaticKeepAliveClientMixin {
late final TabController _tabController;

@override
Expand All @@ -46,8 +46,12 @@ class _CommunicationsListState extends State<CommunicationsList>
setState(() {});
}

@override
bool get wantKeepAlive => true;

@override
Widget build(BuildContext context) {
super.build(context);
return LayoutBuilder(builder: (context, constraints) {
return Padding(
padding: const EdgeInsets.fromLTRB(0, 0, 0, 20),
Expand Down
1 change: 0 additions & 1 deletion frontend/lib/models/member.dart
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
import 'dart:convert';

import 'package:frontend/models/contact.dart';
import 'package:frontend/models/team.dart';

class Member {
final String id;
Expand Down
23 changes: 17 additions & 6 deletions frontend/lib/routes/HomeScreen.dart
Original file line number Diff line number Diff line change
Expand Up @@ -83,19 +83,19 @@ class _HomeScreenState extends State<HomeScreen> {
child: const SpeakerTable(),
),
Center(
child: LandingPage(),
child: const LandingPage(),
),
Center(
child: CompanyTable(),
child: const CompanyTable(),
),
Center(
child: TeamTable(),
child: const TeamTable(),
),
Center(
child: MeetingPage(),
child: const MeetingPage(),
),
Center(
child: SessionPage(),
child: const SessionPage(),
)
],
),
Expand Down Expand Up @@ -222,11 +222,22 @@ class _HomeScreenState extends State<HomeScreen> {
}
}

class LandingPage extends StatelessWidget {
class LandingPage extends StatefulWidget {
const LandingPage({Key? key}) : super(key: key);

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

class _LandingPageState extends State<LandingPage>
with AutomaticKeepAliveClientMixin {

@override
bool get wantKeepAlive => true;

@override
Widget build(BuildContext context) {
super.build(context);
return Container(
child: Text("Welcome to deck2! In Progress..."),
);
Expand Down
1 change: 1 addition & 0 deletions frontend/lib/routes/company/CompanyTable.dart
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@ class _CompanyTableState extends State<CompanyTable>
final CompanyService _companyService = CompanyService();
late ParticipationStatus _filter;

@override
bool get wantKeepAlive => true;

@override
Expand Down
18 changes: 3 additions & 15 deletions frontend/lib/routes/meeting/MeetingPage.dart
Original file line number Diff line number Diff line change
Expand Up @@ -6,25 +6,14 @@ import 'package:frontend/routes/meeting/MeetingsNotifier.dart';
import 'package:frontend/services/meetingService.dart';
import 'package:provider/provider.dart';

class MeetingPage extends StatelessWidget {
class MeetingPage extends StatefulWidget {
const MeetingPage({Key? key}) : super(key: key);

@override
Widget build(BuildContext context) {
return Container(
child: MeetingList(),
);
}
}

class MeetingList extends StatefulWidget {
const MeetingList({Key? key}) : super(key: key);

@override
_MeetingListState createState() => _MeetingListState();
_MeetingPageState createState() => _MeetingPageState();
}

class _MeetingListState extends State<MeetingList>
class _MeetingPageState extends State<MeetingPage>
with AutomaticKeepAliveClientMixin, SingleTickerProviderStateMixin {
final MeetingService _service = MeetingService();
late final Future<List<Meeting>> _meetings;
Expand All @@ -38,7 +27,6 @@ class _MeetingListState extends State<MeetingList>
}

@override
// TODO: implement wantKeepAlive
bool get wantKeepAlive => true;

@override
Expand Down
6 changes: 3 additions & 3 deletions frontend/lib/routes/meeting/MeetingScreen.dart
Original file line number Diff line number Diff line change
Expand Up @@ -274,7 +274,7 @@ class MeetingParticipants extends StatelessWidget {
onPressed: () => _deleteMeetingParticipant(context,
membs[index]!.id, type, membs[index]!.name),
icon: Icon(Icons.delete),
style: ElevatedButton.styleFrom(primary: Colors.red),
style: ElevatedButton.styleFrom(backgroundColor: Colors.red),
label: const Text("Delete participant")),
]);
});
Expand Down Expand Up @@ -643,7 +643,7 @@ class MeetingBanner extends StatelessWidget {
context),
icon: Icon(Icons.article),
style: ElevatedButton.styleFrom(
primary: meeting
backgroundColor: meeting
.minute!.isNotEmpty
? const Color(
0xFF5C7FF2)
Expand All @@ -666,7 +666,7 @@ class MeetingBanner extends StatelessWidget {
icon: Icon(Icons.article),
style: ElevatedButton
.styleFrom(
primary: const Color(
backgroundColor: const Color(
0xFFF25C5C)),
label: const Text(
"Delete Minutes")))
Expand Down
2 changes: 1 addition & 1 deletion frontend/lib/routes/member/AddMemberForm.dart
Original file line number Diff line number Diff line change
Expand Up @@ -140,7 +140,7 @@ class _AddMemberFormState extends State<AddMemberForm> {
padding: const EdgeInsets.all(8.0),
child: ElevatedButton(
style: ElevatedButton.styleFrom(
primary: Theme.of(context).colorScheme.secondary,
backgroundColor: Theme.of(context).colorScheme.secondary,
padding: EdgeInsets.symmetric(horizontal: 50),
elevation: 2,
shape: RoundedRectangleBorder(
Expand Down
2 changes: 1 addition & 1 deletion frontend/lib/routes/member/EditContact.dart
Original file line number Diff line number Diff line change
Expand Up @@ -195,7 +195,7 @@ class _MyFormState extends State<EditContact> {
padding: const EdgeInsets.all(8.0),
child: ElevatedButton(
style: ElevatedButton.styleFrom(
primary: Theme.of(context).colorScheme.secondary,
backgroundColor: Theme.of(context).colorScheme.secondary,
padding: EdgeInsets.symmetric(horizontal: 50),
elevation: 2,
shape: RoundedRectangleBorder(
Expand Down
2 changes: 0 additions & 2 deletions frontend/lib/routes/session/EditSessionForm.dart
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,6 @@ import 'package:frontend/services/sessionService.dart';
import 'package:intl/intl.dart';
import 'package:provider/provider.dart';
import 'package:flutter_form_builder/flutter_form_builder.dart';
import 'package:dropdown_search/dropdown_search.dart';
import 'package:form_builder_extra_fields/form_builder_extra_fields.dart';

class EditSessionForm extends StatefulWidget {
final Session session;
Expand Down
2 changes: 0 additions & 2 deletions frontend/lib/routes/session/SessionCard.dart
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
import 'package:file_picker/file_picker.dart';
import 'package:flutter/material.dart';
import 'package:frontend/components/blurryDialog.dart';
import 'package:frontend/main.dart';
Expand All @@ -9,7 +8,6 @@ import 'package:frontend/services/authService.dart';
import 'package:frontend/services/sessionService.dart';
import 'package:intl/intl.dart';
import 'package:provider/provider.dart';
import 'package:url_launcher/url_launcher.dart';

class SessionCard extends StatelessWidget {
final Session session;
Expand Down
3 changes: 0 additions & 3 deletions frontend/lib/routes/session/SessionPage.dart
Original file line number Diff line number Diff line change
@@ -1,7 +1,5 @@
import 'package:flutter/material.dart';
import 'package:frontend/main.dart';
import 'package:frontend/models/session.dart';
import 'package:frontend/routes/session/SessionCard.dart';
import 'package:frontend/routes/session/SessionsNotifier.dart';
import 'package:frontend/routes/session/calendar.dart';
import 'package:frontend/services/sessionService.dart';
Expand Down Expand Up @@ -40,7 +38,6 @@ class _SessionListState extends State<SessionList>
}

@override
// TODO: implement wantKeepAlive
bool get wantKeepAlive => true;

@override
Expand Down
61 changes: 61 additions & 0 deletions frontend/lib/routes/speaker/DetailsScreen.dart
Original file line number Diff line number Diff line change
@@ -0,0 +1,61 @@
import 'package:flutter/material.dart';
import 'package:frontend/components/EditableCard.dart';
import 'package:frontend/models/speaker.dart';

class DetailsScreen extends StatefulWidget {
final Speaker speaker;
const DetailsScreen({Key? key, required this.speaker}) : super(key: key);

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

class _DetailsScreenState extends State<DetailsScreen>
with AutomaticKeepAliveClientMixin {

@override
bool get wantKeepAlive => true;

@override
Widget build(BuildContext context) {
super.build(context);
return Padding(
padding: const EdgeInsets.all(8.0),
child: Container(
child: ListView(
children: [
Padding(
padding: const EdgeInsets.all(8.0),
child: EditableCard(
title: 'Bio',
body: widget.speaker.bio ?? "",
bodyEditedCallback: (newBio) {
//speaker.bio = newBio;
//TODO replace bio with service call to change bio
print('replaced bio');
return Future.delayed(Duration.zero);
},
isSingleline: false,
textInputType: TextInputType.multiline,
),
),
Padding(
padding: const EdgeInsets.fromLTRB(8.0, 0, 8.0, 8.0),
child: EditableCard(
title: 'Notes',
body: widget.speaker.notes ?? "",
bodyEditedCallback: (newNotes) {
//speaker.bio = newBio;
//TODO replace bio with service call to change bio
print('replaced notes');
return Future.delayed(Duration.zero);
},
isSingleline: false,
textInputType: TextInputType.multiline,
),
),
],
)),
);
}
}
1 change: 0 additions & 1 deletion frontend/lib/routes/speaker/EditSpeakerForm.dart
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,6 @@ import 'package:dotted_border/dotted_border.dart';
import 'package:flutter/foundation.dart';
import 'package:flutter/material.dart';
import 'package:flutter_dropzone/flutter_dropzone.dart';
import 'package:frontend/components/appbar.dart';
import 'package:frontend/models/speaker.dart';
import 'package:frontend/services/speakerService.dart';
import 'package:image_picker/image_picker.dart';
Expand Down
60 changes: 60 additions & 0 deletions frontend/lib/routes/speaker/ParticipationList.dart
Original file line number Diff line number Diff line change
@@ -0,0 +1,60 @@
import 'package:flutter/material.dart';
import 'package:frontend/components/participationCard.dart';
import 'package:frontend/main.dart';
import 'package:frontend/models/speaker.dart';

class ParticipationList extends StatefulWidget {
final Speaker speaker;
final Future<void> Function(Map<String, dynamic>) onParticipationChanged;
final void Function() onParticipationDeleted;
const ParticipationList({
Key? key,
required this.speaker,
required this.onParticipationChanged,
required this.onParticipationDeleted,
}) : super(key: key);

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

class _ParticipationListState extends State<ParticipationList>
with AutomaticKeepAliveClientMixin {

@override
bool get wantKeepAlive => true;

@override
Widget build(BuildContext context) {
super.build(context);
return LayoutBuilder(
builder: (context, constraints) {
bool small = constraints.maxWidth < App.SIZE;
if (widget.speaker.participations != null) {
return Padding(
padding: const EdgeInsets.all(8.0),
child: Container(
child: ListView(
controller: ScrollController(),
children: widget.speaker.participations!.reversed
.map((e) => Padding(
padding: const EdgeInsets.all(8.0),
child: ParticipationCard(
participation: e,
small: small,
type: CardType.SPEAKER,
onEdit: widget.onParticipationChanged,
onDelete: widget.onParticipationDeleted,
),
))
.toList(),
),
),
);
} else {
return Container();
}
},
);
}
}
Loading

0 comments on commit ced347f

Please sign in to comment.