Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Feat/strategic badge #517

Merged
merged 2 commits into from
Jan 7, 2025
Merged
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
154 changes: 79 additions & 75 deletions lib/api_base/schema.graphql
Original file line number Diff line number Diff line change
Expand Up @@ -15,10 +15,6 @@ type Query {
Scientific_Circles_Links_by_id(id: ID!, version: String): Scientific_Circles_Links
Scientific_Circles_Links_aggregated(groupBy: [String], filter: Scientific_Circles_Links_filter, limit: Int, offset: Int, page: Int, search: String, sort: [String]): [Scientific_Circles_Links_aggregated!]!
Scientific_Circles_Links_by_version(version: String!, id: ID!): version_Scientific_Circles_Links
Scientific_Circles(filter: Scientific_Circles_filter, sort: [String], limit: Int, offset: Int, page: Int, search: String): [Scientific_Circles!]!
Scientific_Circles_by_id(id: ID!, version: String): Scientific_Circles
Scientific_Circles_aggregated(groupBy: [String], filter: Scientific_Circles_filter, limit: Int, offset: Int, page: Int, search: String, sort: [String]): [Scientific_Circles_aggregated!]!
Scientific_Circles_by_version(version: String!, id: ID!): version_Scientific_Circles
Posts(filter: Posts_filter, sort: [String], limit: Int, offset: Int, page: Int, search: String): [Posts!]!
Posts_by_id(id: ID!, version: String): Posts
Posts_aggregated(groupBy: [String], filter: Posts_filter, limit: Int, offset: Int, page: Int, search: String, sort: [String]): [Posts_aggregated!]!
Expand Down Expand Up @@ -85,6 +81,10 @@ type Query {
Changelog_Screenshots_by_id(id: ID!, version: String): Changelog_Screenshots
Changelog_Screenshots_aggregated(groupBy: [String], filter: Changelog_Screenshots_filter, limit: Int, offset: Int, page: Int, search: String, sort: [String]): [Changelog_Screenshots_aggregated!]!
Changelog_Screenshots_by_version(version: String!, id: ID!): version_Changelog_Screenshots
Scientific_Circles(filter: Scientific_Circles_filter, sort: [String], limit: Int, offset: Int, page: Int, search: String): [Scientific_Circles!]!
Scientific_Circles_by_id(id: ID!, version: String): Scientific_Circles
Scientific_Circles_aggregated(groupBy: [String], filter: Scientific_Circles_filter, limit: Int, offset: Int, page: Int, search: String, sort: [String]): [Scientific_Circles_aggregated!]!
Scientific_Circles_by_version(version: String!, id: ID!): version_Scientific_Circles
}

type Scientific_Circles_Tags {
Expand All @@ -111,6 +111,7 @@ type Scientific_Circles {
department(filter: Departments_filter, sort: [String], limit: Int, offset: Int, page: Int, search: String): Departments
desc2: String
useCoverAsPreviewPhoto: Boolean
isStrategic: Boolean!
tags(filter: Scientific_Circles_Tags_filter, sort: [String], limit: Int, offset: Int, page: Int, search: String): [Scientific_Circles_Tags]
tags_func: count_functions
links(filter: Scientific_Circles_Links_filter, sort: [String], limit: Int, offset: Int, page: Int, search: String): [Scientific_Circles_Links]
Expand Down Expand Up @@ -397,6 +398,7 @@ input Scientific_Circles_filter {
department: Departments_filter
desc2: string_filter_operators
useCoverAsPreviewPhoto: boolean_filter_operators
isStrategic: boolean_filter_operators
tags: Scientific_Circles_Tags_filter
tags_func: count_function_filter_operators
links: Scientific_Circles_Links_filter
Expand Down Expand Up @@ -610,70 +612,6 @@ type version_Scientific_Circles_Links {
scientific_circle_id: JSON
}

type Scientific_Circles_aggregated {
group: JSON
countAll: Int
count: Scientific_Circles_aggregated_count
countDistinct: Scientific_Circles_aggregated_count
avg: Scientific_Circles_aggregated_fields
sum: Scientific_Circles_aggregated_fields
avgDistinct: Scientific_Circles_aggregated_fields
sumDistinct: Scientific_Circles_aggregated_fields
min: Scientific_Circles_aggregated_fields
max: Scientific_Circles_aggregated_fields
}

type Scientific_Circles_aggregated_count {
id: Int
status: Int
sort: Int
date_created: Int
date_updated: Int
name: Int
logo: Int
cover: Int
description: Int
type: Int
source: Int
shortDescription: Int
department: Int
desc2: Int
useCoverAsPreviewPhoto: Int
tags: Int
links: Int
}

type Scientific_Circles_aggregated_fields {
id: Float
sort: Float
department: Float
}

""""""
type version_Scientific_Circles {
id: ID!
status: String
sort: Int
date_created: Date
date_created_func: datetime_functions
date_updated: Date
date_updated_func: datetime_functions
name: String!
logo: JSON
cover: JSON
description: String
type: String
source: String
shortDescription: String
department: JSON
desc2: String
useCoverAsPreviewPhoto: Boolean
tags: JSON
tags_func: count_functions
links: JSON
links_func: count_functions
}

type Posts_aggregated {
group: JSON
countAll: Int
Expand Down Expand Up @@ -1610,13 +1548,78 @@ type version_Changelog_Screenshots {
screenshot_preview: JSON
}

type Scientific_Circles_aggregated {
group: JSON
countAll: Int
count: Scientific_Circles_aggregated_count
countDistinct: Scientific_Circles_aggregated_count
avg: Scientific_Circles_aggregated_fields
sum: Scientific_Circles_aggregated_fields
avgDistinct: Scientific_Circles_aggregated_fields
sumDistinct: Scientific_Circles_aggregated_fields
min: Scientific_Circles_aggregated_fields
max: Scientific_Circles_aggregated_fields
}

type Scientific_Circles_aggregated_count {
id: Int
status: Int
sort: Int
date_created: Int
date_updated: Int
name: Int
logo: Int
cover: Int
description: Int
type: Int
source: Int
shortDescription: Int
department: Int
desc2: Int
useCoverAsPreviewPhoto: Int
isStrategic: Int
tags: Int
links: Int
}

type Scientific_Circles_aggregated_fields {
id: Float
sort: Float
department: Float
}

""""""
type version_Scientific_Circles {
id: ID!
status: String
sort: Int
date_created: Date
date_created_func: datetime_functions
date_updated: Date
date_updated_func: datetime_functions
name: String!
logo: JSON
cover: JSON
description: String
type: String
source: String
shortDescription: String
department: JSON
desc2: String
useCoverAsPreviewPhoto: Boolean
isStrategic: Boolean!
tags: JSON
tags_func: count_functions
links: JSON
links_func: count_functions
}

type Subscription {
directus_files_mutated(event: EventEnum): directus_files_mutated
Scientific_Circles_Tags_mutated(event: EventEnum): Scientific_Circles_Tags_mutated
Tags_mutated(event: EventEnum): Tags_mutated
Posts_Tags_mutated(event: EventEnum): Posts_Tags_mutated
Scientific_Circles_Links_mutated(event: EventEnum): Scientific_Circles_Links_mutated
Scientific_Circles_mutated(event: EventEnum): Scientific_Circles_mutated
Posts_mutated(event: EventEnum): Posts_mutated
AcademicCalendarData_mutated(event: EventEnum): AcademicCalendarData_mutated
WeekExceptions_mutated(event: EventEnum): WeekExceptions_mutated
Expand All @@ -1635,6 +1638,7 @@ type Subscription {
Changelog_mutated(event: EventEnum): Changelog_mutated
Changelog_Change_mutated(event: EventEnum): Changelog_Change_mutated
Changelog_Screenshots_mutated(event: EventEnum): Changelog_Screenshots_mutated
Scientific_Circles_mutated(event: EventEnum): Scientific_Circles_mutated
}

type directus_files_mutated {
Expand Down Expand Up @@ -1673,12 +1677,6 @@ type Scientific_Circles_Links_mutated {
data: Scientific_Circles_Links
}

type Scientific_Circles_mutated {
key: ID!
event: EventEnum
data: Scientific_Circles
}

type Posts_mutated {
key: ID!
event: EventEnum
Expand Down Expand Up @@ -1785,4 +1783,10 @@ type Changelog_Screenshots_mutated {
key: ID!
event: EventEnum
data: Changelog_Screenshots
}

type Scientific_Circles_mutated {
key: ID!
event: EventEnum
data: Scientific_Circles
}
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: sciClub.isStrategic,
),
);
},
Expand Down
16 changes: 6 additions & 10 deletions lib/features/home_view/widgets/science_clubs_section.dart
Original file line number Diff line number Diff line change
Expand Up @@ -71,8 +71,7 @@ class _ScienceClubsDataList extends ConsumerWidget {
itemCount: scienceClubs.length,
itemBuilder: (BuildContext context, int index) {
final sciClub = scienceClubs[index];
final sciClubCard = _BuildScienceClubCard(sciClub: sciClub, ref: ref);

final sciClubCard = _ScienceClubCard(sciClub: sciClub);
if (index != scienceClubs.length - 1) {
return MediumLeftPadding(
child: sciClubCard,
Expand All @@ -87,25 +86,22 @@ class _ScienceClubsDataList extends ConsumerWidget {
}
}

class _BuildScienceClubCard extends StatelessWidget {
const _BuildScienceClubCard({
required this.sciClub,
required this.ref,
});
class _ScienceClubCard extends ConsumerWidget {
const _ScienceClubCard({required this.sciClub});

final ScienceClub sciClub;
final WidgetRef ref;

@override
Widget build(BuildContext context) {
Widget build(BuildContext context, WidgetRef ref) {
return BigPreviewCard(
title: sciClub.name,
shortDescription: sciClub.shortDescription ?? "",
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),
showStrategicBadge: sciClub.isStrategic,
);
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -16,5 +16,6 @@ query GetScienceClubDetails($id: ID!) {
department {
name
}
isStrategic
}
}
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(),
if (value.isStrategic) const StrategicBadge(),
],
),
),
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -24,5 +24,6 @@ query GetScienceClubs {
filename_disk
}
useCoverAsPreviewPhoto
isStrategic
}
}
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
Loading
Loading