Skip to content

Commit

Permalink
feat(science-clubs): add verified badge UI
Browse files Browse the repository at this point in the history
  • Loading branch information
simon-the-shark committed Jan 7, 2025
1 parent f5e0182 commit 57972c5
Show file tree
Hide file tree
Showing 11 changed files with 122 additions and 70 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,6 @@ import "../../navigator/utils/navigation_commands.dart";
import "../../science_clubs_view/repository/science_clubs_repository.dart";
import "../repository/department_details_repository.dart";

// TODO(simon-the-shark): Resolve if the list button should redirect to list of all study circles or only ones related to the department., #165
class DepartmentScienceClubsSection extends ConsumerWidget {
const DepartmentScienceClubsSection(this.department, {super.key});
final DepartmentDetails? department;
Expand Down Expand Up @@ -83,7 +82,8 @@ class _ScienceClubsList extends ConsumerWidget {
? sciClub.cover?.filename_disk
: sciClub.logo?.filename_disk,
onClick: () async => ref.navigateSciClubsDetail(sciClub.id),
showBadge: sciClub.source == ScienceClubsViewConfig.source,
showVerifiedBadge: sciClub.source == ScienceClubsViewConfig.source,
showStrategicBadge: true,
),
);
},
Expand Down
2 changes: 1 addition & 1 deletion lib/features/home_view/widgets/science_clubs_section.dart
Original file line number Diff line number Diff line change
Expand Up @@ -104,7 +104,7 @@ class _BuildScienceClubCard extends StatelessWidget {
directusUrl: (sciClub.useCoverAsPreviewPhoto ?? false)
? sciClub.cover?.filename_disk
: sciClub.logo?.filename_disk,
showBadge: sciClub.source == ScienceClubsViewConfig.source,
showVerifiedBadge: sciClub.source == ScienceClubsViewConfig.source,
onClick: () async => ref.navigateSciClubsDetail(sciClub.id),
);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,8 @@ import "../../widgets/loading_widgets/contact_section_loading.dart";
import "../../widgets/loading_widgets/header_section_loading.dart";
import "../../widgets/loading_widgets/shimmer_loading.dart";
import "../../widgets/my_error_widget.dart";
import "../science_clubs_view/widgets/strategic_badge.dart";
import "../science_clubs_view/widgets/verified_badge.dart";
import "repository/science_club_details_repository.dart";
import "widgets/about_us_section.dart";
import "widgets/about_us_section_loading.dart";
Expand Down Expand Up @@ -69,21 +71,8 @@ class _SciClubDetailDataView extends ConsumerWidget {
style: context.textTheme.headline,
children: [
if (value.source == ScienceClubsViewConfig.source)
WidgetSpan(
baseline: TextBaseline.ideographic,
alignment: PlaceholderAlignment.middle,
child: SizedBox.square(
dimension: 16,
child: Padding(
padding: const EdgeInsets.only(left: 4),
child: Icon(
Icons.verified_sharp,
size: 12,
color: context.colorTheme.orangePomegranade,
),
),
),
),
const VerifiedBadge(),
const StrategicBadge(),
],
),
),
Expand Down
32 changes: 12 additions & 20 deletions lib/features/science_clubs_view/widgets/ensure_visible_tags.dart
Original file line number Diff line number Diff line change
Expand Up @@ -3,9 +3,10 @@ import "dart:math";
import "package:auto_size_text/auto_size_text.dart";
import "package:flutter/material.dart";

import "../../../theme/app_theme.dart";
import "../../../utils/calculate_lines.dart";
import "../../../widgets/dual_text_max_lines.dart";
import "strategic_badge.dart";
import "verified_badge.dart";

class EnsureVisibleTags extends DualTextMaxLines {
/// DualTextMaxLines with third text row that must have at least one line
Expand All @@ -19,20 +20,25 @@ class EnsureVisibleTags extends DualTextMaxLines {
super.key,
this.secondSubtitle,
this.secondSubtitleStyle,
this.badge = false,
super.showVerifiedBadge = false,
super.showStrategicBadge = false,
});

final String? secondSubtitle;
final TextStyle? secondSubtitleStyle;
final bool badge;

@override
Widget build(BuildContext context) {
if (secondSubtitle == null) {
return super.build(context);
}
final placeholderDimensions = [
if (badge)
if (showVerifiedBadge)
const PlaceholderDimensions(
size: Size(12, 12),
alignment: PlaceholderAlignment.middle,
),
if (showStrategicBadge)
const PlaceholderDimensions(
size: Size(12, 12),
alignment: PlaceholderAlignment.middle,
Expand All @@ -56,22 +62,8 @@ class EnsureVisibleTags extends DualTextMaxLines {
? titleStyle
: titleStyle?.copyWith(fontSize: fontSize),
children: [
if (badge)
WidgetSpan(
baseline: TextBaseline.ideographic,
alignment: PlaceholderAlignment.middle,
child: SizedBox.square(
dimension: 16,
child: Padding(
padding: const EdgeInsets.only(left: 4),
child: Icon(
Icons.verified_sharp,
size: 12,
color: context.colorTheme.orangePomegranade,
),
),
),
),
if (showVerifiedBadge) const VerifiedBadge(),
if (showStrategicBadge) const StrategicBadge(),
],
);

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@ class ScienceClubCard extends StatelessWidget {
.toList()
.join(", "),
showBadge: sciClub.source == ScienceClubsViewConfig.source,
showStrategicBadge: true,
activeShadows: null,
trailing: Padding(
padding: const EdgeInsets.only(
Expand Down
44 changes: 44 additions & 0 deletions lib/features/science_clubs_view/widgets/strategic_badge.dart
Original file line number Diff line number Diff line change
@@ -0,0 +1,44 @@
import "package:flutter/material.dart";

import "../../../theme/app_theme.dart";

class StrategicBadge extends WidgetSpan {
const StrategicBadge()
: super(
baseline: TextBaseline.ideographic,
alignment: PlaceholderAlignment.middle,
child: const SizedBox.square(
dimension: 16,
child: _StrategicBadgeWidget(),
),
);
}

class _StrategicBadgeWidget extends StatelessWidget {
const _StrategicBadgeWidget();

@override
Widget build(BuildContext context) {
return Tooltip(
message: "Koło strategiczne PWr",
child: Stack(
children: [
Center(
child: Icon(
Icons.shield,
size: 14,
color: context.colorTheme.blueAzure,
),
),
Align(
alignment: const Alignment(0, -1 / 4),
child: Text(
context.localize.strategic_club_abbr,
style: context.textTheme.bodyWhite.copyWith(fontSize: 6),
),
),
],
),
);
}
}
31 changes: 31 additions & 0 deletions lib/features/science_clubs_view/widgets/verified_badge.dart
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
import "package:flutter/material.dart";

import "../../../theme/app_theme.dart";

class VerifiedBadge extends WidgetSpan {
const VerifiedBadge()
: super(
baseline: TextBaseline.ideographic,
alignment: PlaceholderAlignment.middle,
child: const _VerifiedBadgeWidget(),
);
}

class _VerifiedBadgeWidget extends StatelessWidget {
const _VerifiedBadgeWidget();

@override
Widget build(BuildContext context) {
return SizedBox.square(
dimension: 16,
child: Padding(
padding: const EdgeInsets.only(left: 4),
child: Icon(
Icons.verified_sharp,
size: 12,
color: context.colorTheme.orangePomegranade,
),
),
);
}
}
10 changes: 3 additions & 7 deletions lib/l10n/app_pl.arb
Original file line number Diff line number Diff line change
Expand Up @@ -241,11 +241,7 @@
"are_lowered_curbs" : "Krawężniki w okolicach budynku {value, select, false{nie} other{}} są obniżone. ",
"are_no_barriers": "Wokół budynku {value, select, true{nie ma barier uniemożliwiających dojścia} false{znajdują się bariery uniemożliwiające dojście} other{}} do budynku. ",
"is_path_to_accessible_entrance_marked" : "Ścieżka do wejścia dostępnego dla osób z niepełnosprawnościami {value, select, false{nie} other{}} jest wyraźnie oznaczona. ",
"is_noisy_street_near_building" : "W okolicy {value, select, false{nie ma ruchliwej, hałaśliwej ulicy. } true{znajduje się ruchliwa, hałaśliwa ulica. } other{}}"






"is_noisy_street_near_building" : "W okolicy {value, select, false{nie ma ruchliwej, hałaśliwej ulicy. } true{znajduje się ruchliwa, hałaśliwa ulica. } other{}}",
"strategicBadgeTooltip": "Koło Strategiczne PWr",
"strategic_club_abbr": "KS"
}
9 changes: 6 additions & 3 deletions lib/widgets/big_preview_card.dart
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,8 @@ class BigPreviewCard extends StatelessWidget {
this.date,
required this.onClick,
this.boxFit = BoxFit.scaleDown,
this.showBadge = false,
this.showVerifiedBadge = false,
this.showStrategicBadge = false,
});

final String title;
Expand All @@ -25,7 +26,8 @@ class BigPreviewCard extends StatelessWidget {
final DateTime? date;
final VoidCallback? onClick;
final BoxFit boxFit;
final bool showBadge;
final bool showVerifiedBadge;
final bool showStrategicBadge;

@override
Widget build(BuildContext context) {
Expand Down Expand Up @@ -80,7 +82,8 @@ class BigPreviewCard extends StatelessWidget {
subtitleStyle: context.textTheme.body,
spacing: 7,
maxTotalLines: 8,
showBadge: showBadge,
showVerifiedBadge: showVerifiedBadge,
showStrategicBadge: showStrategicBadge,
),
const Spacer(),
MaterialButton(
Expand Down
32 changes: 11 additions & 21 deletions lib/widgets/dual_text_max_lines.dart
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
import "package:flutter/material.dart";

import "../theme/colors.dart";
import "../features/science_clubs_view/widgets/strategic_badge.dart";
import "../features/science_clubs_view/widgets/verified_badge.dart";

class DualTextSpan extends TextSpan {
DualTextSpan(
Expand All @@ -10,28 +11,15 @@ class DualTextSpan extends TextSpan {
TextStyle? subtitleStyle,
double spacing, {
bool showBadge = false,
bool showStrategicBadge = false,
}) : super(
children: [
TextSpan(
text: title,
style: titleStyle,
children: [
if (showBadge)
const WidgetSpan(
baseline: TextBaseline.ideographic,
alignment: PlaceholderAlignment.middle,
child: SizedBox.square(
dimension: 16,
child: Padding(
padding: EdgeInsets.only(left: 4),
child: Icon(
Icons.verified_sharp,
size: 12,
color: ColorsConsts.orangePomegranade,
),
),
),
),
if (showBadge) const VerifiedBadge(),
if (showStrategicBadge) const StrategicBadge(),
],
),
if (subtitle != null)
Expand All @@ -56,7 +44,8 @@ class DualTextMaxLines extends StatelessWidget {
this.titleStyle,
this.subtitleStyle,
this.spacing = 0,
this.showBadge = false,
this.showVerifiedBadge = false,
this.showStrategicBadge = false,
super.key,
});

Expand All @@ -66,8 +55,8 @@ class DualTextMaxLines extends StatelessWidget {
final TextStyle? subtitleStyle;
final double spacing;
final int maxTotalLines;
final bool showBadge;

final bool showVerifiedBadge;
final bool showStrategicBadge;
@override
Widget build(BuildContext context) {
return RichText(
Expand All @@ -79,7 +68,8 @@ class DualTextMaxLines extends StatelessWidget {
subtitle,
subtitleStyle,
spacing,
showBadge: showBadge,
showBadge: showVerifiedBadge,
showStrategicBadge: showStrategicBadge,
),
);
}
Expand Down
8 changes: 7 additions & 1 deletion lib/widgets/wide_tile_card.dart
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,7 @@ class WideTileCard extends StatelessWidget {
this.crossAxisAlignment = CrossAxisAlignment.start,
super.key,
this.showBadge = false,
this.showStrategicBadge = false,
});

final String title;
Expand All @@ -55,6 +56,7 @@ class WideTileCard extends StatelessWidget {
final LinearGradient? activeGradient;
final CrossAxisAlignment crossAxisAlignment;
final bool showBadge;
final bool showStrategicBadge;
@override
Widget build(BuildContext context) {
return ClipRRect(
Expand All @@ -78,6 +80,7 @@ class WideTileCard extends StatelessWidget {
subtitle,
secondSubtitle,
showBadge: showBadge,
showStrategicBadge: showStrategicBadge,
isActive: isActive,
),
),
Expand All @@ -98,13 +101,15 @@ class _TitlesColumn extends StatelessWidget {
this.secondSubtitle, {
required this.isActive,
this.showBadge = false,
this.showStrategicBadge = false,
});

final String title;
final String? subtitle;
final String? secondSubtitle;
final bool isActive;
final bool showBadge;
final bool showStrategicBadge;
@override
Widget build(BuildContext context) {
return LayoutBuilder(
Expand Down Expand Up @@ -132,7 +137,8 @@ class _TitlesColumn extends StatelessWidget {
? context.textTheme.bodyWhite
: context.textTheme.bodyBlue,
maxTotalLines: 4,
badge: showBadge,
showVerifiedBadge: showBadge,
showStrategicBadge: true,
),
);
},
Expand Down

0 comments on commit 57972c5

Please sign in to comment.