Skip to content

Commit

Permalink
Hotfixes (#167)
Browse files Browse the repository at this point in the history
* Bump app version

* Update packages

* Fix bug with the sponsor enums

* Update sponsor layouts

* Fix data loading of sponsors

* Load company organisers

* Unify fetching of organisers

* Fix formatting

* Fix color issue on the search bar text

* Fix side scroll not updating the indicated tab

* Clear the local database when logging out

* Add an empty state for feed

* Request to sign in a user

* Move static strings to an arb file

* Go to the decision page after a logout

* Enable feedback only if a user is signed in

* Allow access to pages without a token

* Remove guarded zone

* Fix bug with loading the images of organisers

* Fix formatting
  • Loading branch information
MillerAdulu authored Nov 5, 2024
1 parent 793af1e commit efd5fbd
Show file tree
Hide file tree
Showing 41 changed files with 543 additions and 384 deletions.
8 changes: 5 additions & 3 deletions lib/bootstrap.dart
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@ class AppBlocObserver extends BlocObserver {
}

Future<void> bootstrap(FutureOr<Widget> Function() builder) async {
await runZonedGuarded(() async {
try {
Bloc.observer = const AppBlocObserver();

await Firebase.initializeApp(
Expand Down Expand Up @@ -86,6 +86,7 @@ Future<void> bootstrap(FutureOr<Widget> Function() builder) async {
create: (_) => LogOutCubit(
authRepository: getIt(),
hiveRepository: getIt(),
dbRepository: getIt(),
),
),
BlocProvider<FetchFeedCubit>(
Expand Down Expand Up @@ -129,6 +130,7 @@ Future<void> bootstrap(FutureOr<Widget> Function() builder) async {
apiRepository: getIt(),
dBRepository: getIt(),
notificationService: getIt(),
hiveRepository: getIt(),
),
),
BlocProvider<ShareFeedPostCubit>(
Expand Down Expand Up @@ -156,7 +158,7 @@ Future<void> bootstrap(FutureOr<Widget> Function() builder) async {
child: await builder(),
),
);
}, (error, stackTrace) {
} catch (error, stackTrace) {
if (kDebugMode) {
log(error.toString(), stackTrace: stackTrace);
} else {
Expand All @@ -169,5 +171,5 @@ Future<void> bootstrap(FutureOr<Widget> Function() builder) async {
return true;
};
}
});
}
}
8 changes: 8 additions & 0 deletions lib/common/data/enums/organiser_type.dart
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
import 'package:freezed_annotation/freezed_annotation.dart';

enum OrganiserType {
@JsonValue('individual')
individual,
@JsonValue('company')
company;
}
27 changes: 11 additions & 16 deletions lib/common/data/enums/sponsor_type.dart
Original file line number Diff line number Diff line change
@@ -1,21 +1,16 @@
import 'package:freezed_annotation/freezed_annotation.dart';

enum SponsorType {
@JsonValue('platinum')
platinum,
@JsonValue('swag')
swag,
@JsonValue('startup')
startup,
venue;

static SponsorType fromValue(String value) {
switch (value) {
case 'platinum':
return SponsorType.platinum;
case 'swag':
return SponsorType.swag;
case 'startup':
return SponsorType.startup;
case 'venue':
return SponsorType.venue;
default:
throw Exception('Unknown sponsor type: $value');
}
}
@JsonValue('venue')
venue,
@JsonValue('bronze')
bronze,
@JsonValue('gold')
gold;
}
31 changes: 0 additions & 31 deletions lib/common/data/models/individual_organiser.dart

This file was deleted.

14 changes: 11 additions & 3 deletions lib/common/data/models/local/local_organiser.dart
Original file line number Diff line number Diff line change
Expand Up @@ -5,14 +5,22 @@ part 'local_organiser.g.dart';
@collection
class LocalOrganiser {
LocalOrganiser({
required this.serverId,
required this.logo,
required this.name,
required this.type,
required this.tagline,
required this.bio,
required this.designation,
});

Id id = Isar.autoIncrement;
@Index(unique: true, replace: true)
late int serverId;

late String logo;
@Index(unique: true, replace: true)
late String name;
late String type;
@Enumerated(EnumType.name)
late String tagline;
late String bio;
late String designation;
}
4 changes: 3 additions & 1 deletion lib/common/data/models/local/local_sponsor.dart
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
import 'package:fluttercon/common/data/enums/sponsor_type.dart';
import 'package:isar/isar.dart';

part 'local_sponsor.g.dart';
Expand All @@ -18,7 +19,8 @@ class LocalSponsor {
late String name;
late String tagline;
late String link;
late String sponsorType;
@Enumerated(EnumType.name)
late SponsorType sponsorType;
late String logo;
late String createdAt;
}
7 changes: 5 additions & 2 deletions lib/common/data/models/organisers.dart
Original file line number Diff line number Diff line change
Expand Up @@ -6,9 +6,12 @@ part 'organisers.freezed.dart';
@freezed
class Organiser with _$Organiser {
factory Organiser({
required int id,
required String logo,
@JsonKey(name: 'photo') required String logo,
required String name,
@JsonEnum() required String type,
required String tagline,
required String bio,
required String designation,
}) = _Organiser;

factory Organiser.fromJson(Map<String, Object?> json) =>
Expand Down
3 changes: 2 additions & 1 deletion lib/common/data/models/sponsor.dart
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
import 'package:fluttercon/common/data/enums/sponsor_type.dart';
import 'package:freezed_annotation/freezed_annotation.dart';

part 'sponsor.freezed.dart';
Expand All @@ -9,7 +10,7 @@ class Sponsor with _$Sponsor {
String name,
String tagline,
String link,
@JsonKey(name: 'sponsor_type') String sponsorType,
@JsonEnum() @JsonKey(name: 'sponsor_type') SponsorType sponsorType,
String logo,
@JsonKey(name: 'created_at') String createdAt,
) = _Sponsor;
Expand Down
24 changes: 2 additions & 22 deletions lib/common/repository/api_repository.dart
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
import 'package:fluttercon/common/data/models/feed.dart';
import 'package:fluttercon/common/data/models/feedback_dto.dart';
import 'package:fluttercon/common/data/models/individual_organiser.dart';
import 'package:fluttercon/common/data/models/models.dart';
import 'package:fluttercon/common/data/models/sponsor.dart';
import 'package:fluttercon/common/utils/env/flavor_config.dart';
Expand All @@ -12,6 +11,7 @@ class ApiRepository {
final _networkUtil = NetworkUtil();

final _eventSlug = FlutterConConfig.instance!.values.eventSlug;
final _organiserSlug = FlutterConConfig.instance!.values.organiserSlug;

Future<List<Speaker>> fetchSpeakers({
int perPage = 100,
Expand Down Expand Up @@ -79,7 +79,7 @@ class ApiRepository {
}) async {
try {
final response = await _networkUtil.getReq(
'/organizers',
'/organizers/$_organiserSlug/team',
queryParameters: {'per_page': perPage, 'page': page},
);

Expand All @@ -105,26 +105,6 @@ class ApiRepository {
}
}

Future<List<IndividualOrganiser>> fetchIndividualOrganisers({
int perPage = 20,
int page = 1,
}) async {
try {
final response = await _networkUtil.getReq(
'/organizers/droidcon-ke-645/team',
queryParameters: {
'per_page': perPage,
'page': page,
'type': 'individual',
},
);

return IndividualOrganiserResponse.fromJson(response).data;
} catch (e) {
rethrow;
}
}

Future<String> bookmarkSession(int sessionId) async {
try {
final response = await _networkUtil.postReq(
Expand Down
1 change: 0 additions & 1 deletion lib/common/repository/auth_repository.dart
Original file line number Diff line number Diff line change
Expand Up @@ -86,7 +86,6 @@ class AuthRepository {
Future<void> logOut() async {
try {
await _googleSignIn.signOut();
await _networkUtil.postReq('/logout');
} catch (e) {
rethrow;
}
Expand Down
42 changes: 12 additions & 30 deletions lib/common/repository/db_repository.dart
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import 'package:fluttercon/common/data/enums/bookmark_status.dart';
import 'package:fluttercon/common/data/enums/organiser_type.dart';
import 'package:fluttercon/common/data/models/feed.dart';
import 'package:fluttercon/common/data/models/individual_organiser.dart';
import 'package:fluttercon/common/data/models/local/local_feed.dart';
import 'package:fluttercon/common/data/models/local/local_individual_organiser.dart';
import 'package:fluttercon/common/data/models/local/local_organiser.dart';
Expand Down Expand Up @@ -105,47 +105,29 @@ class DBRepository {
localOrganisers.add(
LocalOrganiser(
name: organiser.name,
serverId: organiser.id,
logo: organiser.logo,
),
);
}

await localDB.localOrganisers.putAll(localOrganisers);
});
}

Future<List<LocalOrganiser>> fetchOrganisers() async {
return localDB.localOrganisers.where().findAll();
}

Future<void> persistIndividualOrganisers({
required List<IndividualOrganiser> organisers,
}) async {
await localDB.writeTxn(() async {
final localIndividualOrganisers = <LocalIndividualOrganiser>[];

for (final organiser in organisers) {
localIndividualOrganisers.add(
LocalIndividualOrganiser(
name: organiser.name,
tagline: organiser.tagline,
link: organiser.link,
type: organiser.type,
bio: organiser.bio,
designation: organiser.designation,
photo: organiser.photo,
twitterHandle: organiser.twitterHandle,
),
);
}

await localDB.localIndividualOrganisers.putAll(localIndividualOrganisers);
await localDB.localOrganisers.putAll(localOrganisers);
});
}

Future<List<LocalIndividualOrganiser>> fetchIndividualOrganisers() async {
return localDB.localIndividualOrganisers.where().findAll();
Future<List<LocalOrganiser>> fetchOrganisers({
required OrganiserType type,
}) async {
return localDB.localOrganisers
.where()
.filter()
.typeEqualTo(type.name)
.not()
.nameContains('Nairobi Gophers')
.findAll();
}

Future<void> persistSponsors({
Expand Down
2 changes: 2 additions & 0 deletions lib/common/utils/env/flavor_config.dart
Original file line number Diff line number Diff line change
Expand Up @@ -4,12 +4,14 @@ class FlutterConValues {
required this.baseDomain,
required this.hiveBox,
required this.eventSlug,
required this.organiserSlug,
});

final String urlScheme;
final String baseDomain;
final String hiveBox;
final String eventSlug;
final String organiserSlug;

String get baseUrl => '$urlScheme://$baseDomain';
}
Expand Down
1 change: 1 addition & 0 deletions lib/common/utils/network.dart
Original file line number Diff line number Diff line change
Expand Up @@ -50,6 +50,7 @@ class NetworkUtil {
PrettyDioLogger(
requestHeader: true,
requestBody: true,
responseBody: false,
),
);
}
Expand Down
13 changes: 11 additions & 2 deletions lib/common/widgets/app_bar/feedback_button.dart
Original file line number Diff line number Diff line change
@@ -1,8 +1,10 @@
import 'package:auto_size_text/auto_size_text.dart';
import 'package:flutter/material.dart';
import 'package:fluttercon/common/repository/hive_repository.dart';
import 'package:fluttercon/common/utils/misc.dart';
import 'package:fluttercon/common/utils/router.dart';
import 'package:fluttercon/common/widgets/bottom_nav/app_nav_icon.dart';
import 'package:fluttercon/core/di/injectable.dart';
import 'package:fluttercon/core/theme/theme_colors.dart';
import 'package:fluttercon/l10n/l10n.dart';
import 'package:go_router/go_router.dart';
Expand All @@ -18,8 +20,15 @@ class FeedbackButton extends StatelessWidget {
return selectedIndex == 0
? const SizedBox()
: InkWell(
onTap: () =>
GoRouter.of(context).push(FlutterConRouter.feedbackRoute),
onTap: () {
final profile = getIt<HiveRepository>().retrieveUser();
if (profile == null) {
GoRouter.of(context).goNamed(FlutterConRouter.signInRoute);
return;
}

GoRouter.of(context).push(FlutterConRouter.feedbackRoute);
},
child: Container(
height: 30,
width: 127,
Expand Down
2 changes: 1 addition & 1 deletion lib/common/widgets/app_bar/logout_dialog.dart
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ class _LogOutDialogState extends State<LogOutDialog> {
loaded: () {
GoRouter.of(context)
..pop()
..go(FlutterConRouter.signInRoute);
..go(FlutterConRouter.decisionRoute);
},
orElse: () {},
);
Expand Down
7 changes: 7 additions & 0 deletions lib/common/widgets/app_bar/user_profile_icon.dart
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ import 'package:flutter/material.dart';
import 'package:fluttercon/common/repository/hive_repository.dart';
import 'package:fluttercon/common/utils/env/flavor_config.dart';
import 'package:fluttercon/common/utils/misc.dart';
import 'package:fluttercon/common/utils/router.dart';
import 'package:fluttercon/common/widgets/app_bar/logout_dialog.dart';
import 'package:fluttercon/core/di/injectable.dart';
import 'package:fluttercon/core/theme/theme_colors.dart';
Expand All @@ -26,6 +27,12 @@ class _UserProfileIconState extends State<UserProfileIcon> {
final l10n = context.l10n;
return InkWell(
onTap: () {
final profile = getIt<HiveRepository>().retrieveUser();
if (profile == null) {
GoRouter.of(context).goNamed(FlutterConRouter.signInRoute);
return;
}

WoltModalSheet.show<dynamic>(
context: context,
barrierDismissible: true,
Expand Down
Loading

0 comments on commit efd5fbd

Please sign in to comment.