Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion lib/api/api_repository.dart
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import 'package:reaxit/config.dart';
import 'package:reaxit/models.dart';
import 'package:reaxit/models/announcement.dart';
import 'package:reaxit/models/thabliod.dart';
import 'package:reaxit/models/thabloid.dart';
import 'package:reaxit/api/exceptions.dart';
import 'package:reaxit/models/vacancie.dart';

Expand Down
2 changes: 1 addition & 1 deletion lib/api/concrexit_api_repository.dart
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ import 'package:reaxit/api/api_repository.dart';
import 'package:reaxit/api/exceptions.dart';
import 'package:reaxit/config.dart';
import 'package:reaxit/models.dart';
import 'package:reaxit/models/thabliod.dart';
import 'package:reaxit/models/thabloid.dart';
import 'package:reaxit/models/vacancie.dart';
import 'package:reaxit/models/announcement.dart';
import 'package:sentry_flutter/sentry_flutter.dart';
Expand Down
5 changes: 3 additions & 2 deletions lib/blocs/album_cubit.dart
Original file line number Diff line number Diff line change
Expand Up @@ -9,8 +9,9 @@ typedef AlbumState = DetailState<Album>;

class AlbumCubit extends Cubit<AlbumState> implements GalleryCubit<AlbumState> {
final ApiRepository api;
final String slug;

AlbumCubit(this.api) : super(const LoadingState());
AlbumCubit(this.api, this.slug) : super(const LoadingState());

@override
Future<void> updateLike({required bool liked, required int index}) async {
Expand Down Expand Up @@ -40,7 +41,7 @@ class AlbumCubit extends Cubit<AlbumState> implements GalleryCubit<AlbumState> {
@override
Future<void> more() async {}

Future<void> load(String slug) async {
Future<void> load() async {
emit(LoadingState.from(state));
try {
final album = await api.getAlbum(slug: slug);
Expand Down
2 changes: 1 addition & 1 deletion lib/blocs/auth_cubit.dart
Original file line number Diff line number Diff line change
Expand Up @@ -150,7 +150,7 @@ class AuthCubit extends Cubit<AuthState> {
Platform.isIOS
? CupertinoClient.defaultSessionConfiguration()
as http.Client
: HttpClient() as http.Client,
: http.Client(),
failedRequestStatusCodes: [
SentryStatusCode(400),
SentryStatusCode.range(405, 499),
Expand Down
2 changes: 1 addition & 1 deletion lib/blocs/thabloid_cubit.dart
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ import 'dart:async';

import 'package:flutter_bloc/flutter_bloc.dart';
import 'package:reaxit/api/api_repository.dart';
import 'package:reaxit/models/thabliod.dart';
import 'package:reaxit/models/thabloid.dart';

class ThabloidCubit extends Cubit<Thabloid> {
static const Duration maxAge = Duration(hours: 1);
Expand Down
2 changes: 1 addition & 1 deletion lib/blocs/thabloid_list_cubit.dart
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ import 'dart:async';
import 'package:reaxit/blocs/list_cubit.dart';
import 'package:reaxit/blocs.dart';
import 'package:reaxit/models.dart';
import 'package:reaxit/models/thabliod.dart';
import 'package:reaxit/models/thabloid.dart';

typedef ThabloidListState = ListState<Thabloid>;

Expand Down
2 changes: 1 addition & 1 deletion lib/models/thabliod.dart → lib/models/thabloid.dart
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import 'package:json_annotation/json_annotation.dart';

part 'thabliod.g.dart';
part 'thabloid.g.dart';

enum DocumentCategory { annual, association, event, minutes, misc }

Expand Down
2 changes: 1 addition & 1 deletion lib/models/thabliod.g.dart → lib/models/thabloid.g.dart

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

11 changes: 8 additions & 3 deletions lib/ui/screens/album_screen.dart
Original file line number Diff line number Diff line change
Expand Up @@ -28,8 +28,10 @@ class _AlbumScreenState extends State<AlbumScreen> {
@override
void initState() {
super.initState();
_cubit = AlbumCubit(RepositoryProvider.of<ApiRepository>(context))
..load(widget.slug);
_cubit = AlbumCubit(
RepositoryProvider.of<ApiRepository>(context),
widget.slug,
)..load();
}

Future<void> _shareAlbum(BuildContext context) async {
Expand All @@ -54,7 +56,10 @@ class _AlbumScreenState extends State<AlbumScreen> {
child: BlocBuilder<AlbumCubit, AlbumState>(
builder: (context, state) {
final Widget body = switch (state) {
ErrorState(message: var message) => ErrorScrollView(message),
ErrorState(message: var message) => ErrorScrollView(
message,
retry: _cubit.load,
),
LoadingState _ => const Center(child: CircularProgressIndicator()),
ResultState(result: var result) => _PhotoGrid(result.photos),
};
Expand Down
12 changes: 9 additions & 3 deletions lib/ui/screens/albums_screen.dart
Original file line number Diff line number Diff line change
Expand Up @@ -71,7 +71,7 @@ class _AlbumsScreenState extends State<AlbumsScreen> {
child: BlocBuilder<AlbumListCubit, AlbumListState>(
builder: (context, listState) {
if (listState.hasException) {
return ErrorScrollView(listState.message!);
return ErrorScrollView(listState.message!, retry: _cubit.load);
} else {
return AlbumListScrollView(
key: const PageStorageKey('albums'),
Expand Down Expand Up @@ -148,7 +148,10 @@ class AlbumsSearchDelegate extends SearchDelegate {
bloc: _cubit..search(query),
builder: (context, listState) {
if (listState.hasException) {
return ErrorScrollView(listState.message!);
return ErrorScrollView(
listState.message!,
retry: () => _cubit.search(query),
);
} else {
return AlbumListScrollView(
key: const PageStorageKey('albums-search'),
Expand All @@ -166,7 +169,10 @@ class AlbumsSearchDelegate extends SearchDelegate {
bloc: _cubit..search(query),
builder: (context, listState) {
if (listState.hasException) {
return ErrorScrollView(listState.message!);
return ErrorScrollView(
listState.message!,
retry: () => _cubit.search(query),
);
} else {
return AlbumListScrollView(
key: const PageStorageKey('albums-search'),
Expand Down
7 changes: 5 additions & 2 deletions lib/ui/screens/calendar_screen.dart
Original file line number Diff line number Diff line change
Expand Up @@ -96,7 +96,7 @@ class _CalendarScreenState extends State<CalendarScreen> {
body: BlocBuilder<CalendarCubit, CalendarState>(
builder: (context, calendarState) {
if (calendarState.hasException) {
return ErrorScrollView(calendarState.message!);
return ErrorScrollView(calendarState.message!, retry: _cubit.load);
} else if (calendarState.isLoading) {
return const Center(child: CircularProgressIndicator());
} else {
Expand Down Expand Up @@ -182,7 +182,10 @@ class CalendarSearchDelegate extends SearchDelegate {
bloc: _cubit..search(query),
builder: (context, calendarState) {
if (calendarState.hasException) {
return ErrorScrollView(calendarState.message!);
return ErrorScrollView(
calendarState.message!,
retry: () => _cubit.search(query),
);
} else if (calendarState.isLoading) {
return const Center(child: CircularProgressIndicator());
} else {
Expand Down
22 changes: 14 additions & 8 deletions lib/ui/screens/event_admin_screen.dart
Original file line number Diff line number Diff line change
Expand Up @@ -166,12 +166,12 @@ class _EventAdminScreenState extends State<EventAdminScreen> {

@override
Widget build(BuildContext context) {
EventAdminCubit cubit = EventAdminCubit(
RepositoryProvider.of<ApiRepository>(context),
eventPk: widget.pk,
);
return BlocProvider(
create:
(context) => EventAdminCubit(
RepositoryProvider.of<ApiRepository>(context),
eventPk: widget.pk,
)..load(),
create: (context) => cubit..load(),
child: Builder(
builder: (context) {
return DefaultTabController(
Expand All @@ -181,7 +181,7 @@ class _EventAdminScreenState extends State<EventAdminScreen> {
builder: (context, state) {
late final Widget body;
if (state.hasException) {
body = ErrorScrollView(state.exception!);
body = ErrorScrollView(state.exception!, retry: cubit.load);
} else if (state.isLoading) {
body = const Center(child: CircularProgressIndicator());
} else {
Expand Down Expand Up @@ -581,7 +581,10 @@ class EventAdminSearchDelegate extends SearchDelegate {
child: BlocBuilder<EventAdminCubit, EventAdminState>(
builder: (context, state) {
if (state.hasException) {
return ErrorScrollView(state.message!);
return ErrorScrollView(
state.message!,
retry: () => _adminCubit..search(query),
);
} else {
return ListView.separated(
key: const PageStorageKey('event-admin-search'),
Expand All @@ -606,7 +609,10 @@ class EventAdminSearchDelegate extends SearchDelegate {
child: BlocBuilder<EventAdminCubit, EventAdminState>(
builder: (context, state) {
if (state.hasException) {
return ErrorScrollView(state.message!);
return ErrorScrollView(
state.message!,
retry: () => _adminCubit..search(query),
);
} else {
return ListView.separated(
key: const PageStorageKey('event-admin-search'),
Expand Down
2 changes: 1 addition & 1 deletion lib/ui/screens/event_screen.dart
Original file line number Diff line number Diff line change
Expand Up @@ -931,7 +931,7 @@ class _EventScreenState extends State<EventScreen> {
if (state.hasException) {
child = RefreshIndicator(
onRefresh: _eventCubit.load,
child: ErrorScrollView(state.message!),
child: ErrorScrollView(state.message!, retry: _eventCubit.load),
);
} else if (state.isLoading && widget.event == null) {
child = const Center(child: CircularProgressIndicator());
Expand Down
21 changes: 11 additions & 10 deletions lib/ui/screens/food_admin_screen.dart
Original file line number Diff line number Diff line change
Expand Up @@ -78,12 +78,12 @@ class _FoodAdminScreenState extends State<FoodAdminScreen> {

@override
Widget build(BuildContext context) {
FoodAdminCubit cubit = FoodAdminCubit(
RepositoryProvider.of<ApiRepository>(context),
foodEventPk: widget.pk,
);
return BlocProvider(
create:
(context) => FoodAdminCubit(
RepositoryProvider.of<ApiRepository>(context),
foodEventPk: widget.pk,
)..load(),
create: (context) => cubit..load(),
child: Builder(
builder: (context) {
return Scaffold(
Expand All @@ -107,14 +107,12 @@ class _FoodAdminScreenState extends State<FoodAdminScreen> {
],
),
body: RefreshIndicator(
onRefresh: () async {
await BlocProvider.of<FoodAdminCubit>(context).load();
},
onRefresh: cubit.load,
child: BlocBuilder<FoodAdminCubit, FoodAdminState>(
builder: (context, state) {
switch (state) {
case ErrorState(message: var message):
return ErrorScrollView(message);
return ErrorScrollView(message, retry: cubit.load);
case LoadingState _:
return const Center(child: CircularProgressIndicator());
case ResultState<List<AdminFoodOrder>>(result: var result):
Expand Down Expand Up @@ -322,7 +320,10 @@ class FoodAdminSearchDelegate extends SearchDelegate {
child: BlocBuilder<FoodAdminCubit, FoodAdminState>(
builder:
(context, state) => switch (state) {
ErrorState(message: var message) => ErrorScrollView(message),
ErrorState(message: var message) => ErrorScrollView(
message,
retry: () => _adminCubit.search(query),
),
LoadingState _ => const SizedBox.shrink(),
ResultState(result: var result) => ListView.separated(
key: const PageStorageKey('food-admin-search'),
Expand Down
4 changes: 2 additions & 2 deletions lib/ui/screens/group_screen.dart
Original file line number Diff line number Diff line change
Expand Up @@ -73,8 +73,8 @@ class _Page extends StatelessWidget {
Widget build(BuildContext context) {
final body = switch (state) {
ErrorState(message: var message) => RefreshIndicator(
onRefresh: () => cubit.load(),
child: ErrorScrollView(message),
onRefresh: cubit.load,
child: ErrorScrollView(message, retry: cubit.load),
),
LoadingState _ when listGroup == null => const Center(
child: CircularProgressIndicator(),
Expand Down
14 changes: 10 additions & 4 deletions lib/ui/screens/groups_screen.dart
Original file line number Diff line number Diff line change
Expand Up @@ -89,8 +89,9 @@ class _GroupsScreenState extends State<GroupsScreen>
children: [
BlocBuilder<CommitteesCubit, GroupsState>(
builder: (context, state) {
final cubit = context.read<CommitteesCubit>();
if (state.message != null) {
return ErrorScrollView(state.message!);
return ErrorScrollView(state.message!, retry: cubit.load);
} else if (state.isLoading) {
return const Padding(
padding: EdgeInsets.all(16),
Expand All @@ -103,8 +104,9 @@ class _GroupsScreenState extends State<GroupsScreen>
),
BlocBuilder<SocietiesCubit, GroupsState>(
builder: (context, state) {
final cubit = context.read<SocietiesCubit>();
if (state.message != null) {
return ErrorScrollView(state.message!);
return ErrorScrollView(state.message!, retry: cubit.load);
} else if (state.isLoading) {
return const Padding(
padding: EdgeInsets.all(16),
Expand All @@ -117,8 +119,9 @@ class _GroupsScreenState extends State<GroupsScreen>
),
BlocBuilder<BoardsCubit, GroupsState>(
builder: (context, state) {
final cubit = context.read<BoardsCubit>();
if (state.message != null) {
return ErrorScrollView(state.message!);
return ErrorScrollView(state.message!, retry: cubit.load);
} else if (state.isLoading) {
return const Padding(
padding: EdgeInsets.all(16),
Expand Down Expand Up @@ -229,7 +232,10 @@ class GroupSearchDelegate extends SearchDelegate {
bloc: _cubit..search(query),
builder: (context, state) {
if (state.message != null) {
return ErrorScrollView(state.message!);
return ErrorScrollView(
state.message!,
retry: () => _cubit.search(query),
);
} else if (state.isLoading) {
return GroupListScrollView(
key: const PageStorageKey('groups-search'),
Expand Down
6 changes: 2 additions & 4 deletions lib/ui/screens/liked_photos_screen.dart
Original file line number Diff line number Diff line change
Expand Up @@ -46,13 +46,11 @@ class _LikedPhotosScreenState extends State<LikedPhotosScreen> {
child: Scaffold(
appBar: ThaliaAppBar(title: const Text('LIKED PHOTOS')),
body: RefreshIndicator(
onRefresh: () async {
await _cubit.load();
},
onRefresh: _cubit.load,
child: BlocBuilder<LikedPhotosCubit, LikedPhotosState>(
builder: (context, state) {
if (state.hasException) {
return ErrorScrollView(state.message!);
return ErrorScrollView(state.message!, retry: _cubit.load);
} else {
return _PhotoGridScrollView(
controller: _controller,
Expand Down
11 changes: 6 additions & 5 deletions lib/ui/screens/members_screen.dart
Original file line number Diff line number Diff line change
Expand Up @@ -59,13 +59,11 @@ class _MembersScreenState extends State<MembersScreen> {
),
drawer: MenuDrawer(),
body: RefreshIndicator(
onRefresh: () async {
await _cubit.load();
},
onRefresh: _cubit.load,
child: BlocBuilder<MemberListCubit, MemberListState>(
builder: (context, listState) {
if (listState.hasException) {
return ErrorScrollView(listState.message!);
return ErrorScrollView(listState.message!, retry: _cubit.load);
} else {
return MemberListScrollView(
key: const PageStorageKey('members'),
Expand Down Expand Up @@ -141,7 +139,10 @@ class MembersSearchDelegate extends SearchDelegate {
bloc: _cubit..search(query),
builder: (context, listState) {
if (listState.hasException) {
return ErrorScrollView(listState.message!);
return ErrorScrollView(
listState.message!,
retry: () => _cubit..search(query),
);
} else {
return MemberListScrollView(
key: const PageStorageKey('members-search'),
Expand Down
5 changes: 3 additions & 2 deletions lib/ui/screens/pay_screen.dart
Original file line number Diff line number Diff line change
Expand Up @@ -10,17 +10,18 @@ import '../../models/payment.dart';
class PayScreen extends StatelessWidget {
@override
Widget build(BuildContext context) {
PaymentUserCubit cubit = BlocProvider.of<PaymentUserCubit>(context);
return Scaffold(
appBar: ThaliaAppBar(title: const Text('THALIA PAY')),
drawer: MenuDrawer(),
body: RefreshIndicator(
onRefresh: () => BlocProvider.of<PaymentUserCubit>(context).load(),
onRefresh: cubit.load,
child: BlocBuilder<PaymentUserCubit, PaymentUserState>(
builder: (context, state) {
if (state.isLoading) {
return const Center(child: CircularProgressIndicator());
} else if (state.hasException) {
return ErrorScrollView(state.message!);
return ErrorScrollView(state.message!, retry: cubit.load);
} else {
return _Body(payments: state.payments!);
}
Expand Down
Loading