Skip to content

Commit

Permalink
Fix bug with loading the images of organisers
Browse files Browse the repository at this point in the history
  • Loading branch information
MillerAdulu committed Nov 5, 2024
1 parent c85e319 commit b2c66d7
Show file tree
Hide file tree
Showing 6 changed files with 58 additions and 20 deletions.
2 changes: 2 additions & 0 deletions lib/common/repository/db_repository.dart
Original file line number Diff line number Diff line change
Expand Up @@ -125,6 +125,8 @@ class DBRepository {
.where()
.filter()
.typeEqualTo(type.name)
.not()
.nameContains('Nairobi Gophers')
.findAll();
}

Expand Down
1 change: 0 additions & 1 deletion lib/common/repository/hive_repository.dart
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,6 @@ class HiveRepository {
}

ThemeMode retrieveThemeMode() {
return ThemeMode.dark;
final themeMode =
Hive.box<dynamic>(FlutterConConfig.instance!.values.hiveBox)
.get('themeMode') as String?;
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
3 changes: 3 additions & 0 deletions lib/common/widgets/resolved_image.dart
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
import 'package:cached_network_image/cached_network_image.dart';
import 'package:flutter/material.dart';
import 'package:flutter_svg/flutter_svg.dart';
import 'package:logger/logger.dart';

class ResolvedImage extends StatelessWidget {
const ResolvedImage({
Expand All @@ -13,11 +14,13 @@ class ResolvedImage extends StatelessWidget {
@override
Widget build(BuildContext context) {
final size = MediaQuery.sizeOf(context);
Logger().d('ResolvedImage: $imageUrl');
return imageUrl.contains('.svg')
? SvgPicture.network(imageUrl)
: CachedNetworkImage(
imageUrl: imageUrl,
height: size.height * .15,
width: size.width * .3,
placeholder: (_, __) => const SizedBox(
height: 150,
width: double.infinity,
Expand Down
24 changes: 17 additions & 7 deletions lib/features/home/widgets/organizers_card.dart
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ class _OrganizersCardState extends State<OrganizersCard> {

@override
Widget build(BuildContext context) {
final (_, colorScheme) = Misc.getTheme(context);
final (isLightMode, colorScheme) = Misc.getTheme(context);
final size = MediaQuery.sizeOf(context);
final l10n = context.l10n;

Expand Down Expand Up @@ -54,14 +54,24 @@ class _OrganizersCardState extends State<OrganizersCard> {
height: size.height * .2,
child: ListView.separated(
scrollDirection: Axis.horizontal,
shrinkWrap: true,
itemBuilder: (context, index) => SizedBox(
width: size.width / 4,
itemBuilder: (context, index) => Container(
height: size.height * .2,
padding: EdgeInsets.symmetric(horizontal: 8.w),
decoration: BoxDecoration(
color: isLightMode
? colorScheme.secondaryContainer
: Colors.white,
borderRadius: BorderRadius.circular(10),
border: Border.all(
color: isLightMode
? Colors.transparent
: colorScheme.primary,
width: 2,
),
),
child: ResolvedImage(imageUrl: organisers[index].logo),
),
separatorBuilder: (_, __) => SizedBox(
width: 8.w,
),
separatorBuilder: (_, __) => SizedBox(width: 4.w),
itemCount: organisers.length,
),
),
Expand Down
47 changes: 35 additions & 12 deletions lib/features/home/widgets/sponsors_card.dart
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ import 'package:fluttercon/common/utils/misc.dart';
import 'package:fluttercon/common/widgets/resolved_image.dart';
import 'package:fluttercon/features/home/cubit/fetch_sponsors_cubit.dart';
import 'package:fluttercon/l10n/l10n.dart';
import 'package:sizer/sizer.dart';

class SponsorsCard extends StatefulWidget {
const SponsorsCard({super.key});
Expand All @@ -25,7 +26,7 @@ class _SponsorsCardState extends State<SponsorsCard> {
Widget build(BuildContext context) {
final size = MediaQuery.sizeOf(context);
final l10n = context.l10n;
final (_, colorScheme) = Misc.getTheme(context);
final (isLightMode, colorScheme) = Misc.getTheme(context);

return Container(
width: double.infinity,
Expand Down Expand Up @@ -56,13 +57,24 @@ class _SponsorsCardState extends State<SponsorsCard> {
.toList();
return Column(
children: [
ResolvedImage(
imageUrl: sponsors
.firstWhere(
(sponsor) =>
sponsor.sponsorType == SponsorType.gold,
)
.logo,
Container(
padding: EdgeInsets.symmetric(horizontal: 8.w),
decoration: BoxDecoration(
color: isLightMode ? colorScheme.secondaryContainer : Colors.white,
borderRadius: BorderRadius.circular(10),
border: Border.all(
color:isLightMode ? Colors.transparent : colorScheme.primary,
width: 2,
),
),
child: ResolvedImage(
imageUrl: sponsors
.firstWhere(
(sponsor) =>
sponsor.sponsorType == SponsorType.gold,
)
.logo,
),
),
const SizedBox(height: 16),
SizedBox(
Expand All @@ -71,10 +83,21 @@ class _SponsorsCardState extends State<SponsorsCard> {
shrinkWrap: true,
scrollDirection: Axis.horizontal,
itemCount: nonPlatinumSponsors.length,
itemBuilder: (context, index) => SizedBox(
width: size.width / 4,
child: ResolvedImage(
imageUrl: nonPlatinumSponsors[index].logo,
itemBuilder: (context, index) => Container(
padding: EdgeInsets.symmetric(horizontal: 8.w),
decoration: BoxDecoration(
color: isLightMode ? colorScheme.secondaryContainer : Colors.white,
borderRadius: BorderRadius.circular(10),
border: Border.all(
color: isLightMode ? Colors.transparent : colorScheme.primary,
width: 2,
),
),
child: SizedBox(
width: size.width / 4,
child: ResolvedImage(
imageUrl: nonPlatinumSponsors[index].logo,
),
),
),
),
Expand Down

0 comments on commit b2c66d7

Please sign in to comment.