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

Refactor/ unify codebase naming #121

Merged
merged 5 commits into from
Aug 3, 2024
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
1 change: 1 addition & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -143,6 +143,7 @@ fvm flutter run
2. Introductions to internationalizing flutter apps (making them available in different languages): https://docs.flutter.dev/ui/accessibility-and-internationalization/internationalization
3. Api helper module instructions: https://github.com/Solvro/topwr-mobile/tree/main/lib/api_base
4. We use `flutter_gen` for generating asset paths: https://pub.dev/packages/flutter_gen
5. For unified names read and follow: [taxonomy.md](./taxonomy.md)

# Before you push a commit
- run the linter
Expand Down
4 changes: 2 additions & 2 deletions lib/api_base/directus_assets_url.dart
Original file line number Diff line number Diff line change
@@ -1,12 +1,12 @@
import "../config/api_base_config.dart";

extension DirectusAssetsUrl on String {
extension DirectusAssetsUrlX on String {
String get directusUrl {
return "${ApiBaseEnv.assetsUrl}/$this";
}
}

extension DirectusAssetsUrlNullable on String? {
extension DirectusAssetsUrlNullableX on String? {
String get directusUrl {
return this?.directusUrl ?? "";
}
Expand Down
10 changes: 5 additions & 5 deletions lib/api_base/ttl/local_timestamp_repository.dart
Original file line number Diff line number Diff line change
Expand Up @@ -9,11 +9,11 @@ import "ttl_timestamp.dart";

part "local_timestamp_repository.g.dart";

class LocalTimestampRepo {
class LocalTimestampRepository {
final TtlKey _key;
final SharedPreferences _prefs;

LocalTimestampRepo(this._key, this._prefs);
LocalTimestampRepository(this._key, this._prefs);

String get _storeKey => "${ApiBaseConfig.ttlPrefsPrefix}$_key";

Expand All @@ -36,10 +36,10 @@ Future<SharedPreferences> _prefs(_PrefsRef ref) async {
}

@riverpod
Future<LocalTimestampRepo> localTimestampRepo(
LocalTimestampRepoRef ref,
Future<LocalTimestampRepository> localTimestampRepository(
LocalTimestampRepositoryRef ref,
TtlKey key,
) async {
final prefs = await ref.watch(_prefsProvider.future);
return LocalTimestampRepo(key, prefs);
return LocalTimestampRepository(key, prefs);
}
4 changes: 2 additions & 2 deletions lib/api_base/ttl/ttl_service.dart
Original file line number Diff line number Diff line change
Expand Up @@ -20,8 +20,8 @@ class TtlService extends _$TtlService {
return FetchPolicy.cacheAndNetwork; // force re-fetch
}

Future<LocalTimestampRepo> get repository async =>
ref.watch(localTimestampRepoProvider.call(key).future);
Future<LocalTimestampRepository> get repository async =>
ref.watch(localTimestampRepositoryProvider.call(key).future);

Future<QueryResult<T>> interceptAndSaveTimestamps<T>(
QueryResult<T> event,
Expand Down
4 changes: 2 additions & 2 deletions lib/api_base/watch_query_adapter.dart
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ class GqlOfflineException implements Exception {
final TtlKey ttlKey;
}

extension _WatchQueryStreamAdapter<T> on Ref {
extension _WatchQueryStreamAdapterX<T> on Ref {
void handleErrors(QueryResult<T> event, TtlKey ttlKey) {
if (!event.hasException) return;

Expand Down Expand Up @@ -39,7 +39,7 @@ extension _WatchQueryStreamAdapter<T> on Ref {
}
}

extension TTLWatchQueryAdapter on AutoDisposeStreamProviderRef {
extension TTLWatchQueryAdapterX on AutoDisposeStreamProviderRef {
Stream<T?> watchQueryWithCache<T>(
WatchQueryOptions<T> watchQueryOptions,
TtlKey ttlKey,
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import "../gen/assets.gen.dart";

abstract class IconsConfig {
abstract class ContactIconsConfig {
static final iconsPaths = {
"facebook": Assets.contactIcons.fb,
"instagram": Assets.contactIcons.ig,
Expand Down
6 changes: 4 additions & 2 deletions lib/config/map_view_config.dart
Original file line number Diff line number Diff line change
Expand Up @@ -36,8 +36,10 @@ abstract class MapWidgetConfig {
);
static const mapType = MapType.normal;

static const mapMarkerOriginWidth = 28;
static const activeMapMarkerOriginWidth = 40;
static const mapMarkerWidth = 22.0;
static const mapMarkerHeight = 34.0;
static const activeMapMarkerWidth = 30.4;
static const activeMapMarkerHeight = 46.4;
}

abstract class BuildingSearchConfig {
Expand Down
22 changes: 11 additions & 11 deletions lib/config/nav_bar_config.dart
Original file line number Diff line number Diff line change
Expand Up @@ -4,19 +4,19 @@ import "package:enum_map/enum_map.dart";
import "package:flutter/material.dart";

import "../features/bottom_nav_bar/bottom_nav_bar_icon_icons.icons.dart";
import "../features/iparking/widgets/i_parking_icons_icons.icons.dart";
import "../features/navigator/app_router.dart";
import "../features/parkings_view/widgets/parkings_icons.icons.dart";

part "nav_bar_config.g.dart";

@unmodifiableEnumMap
enum NavBarEnum {
home(BottomNavBarIcon.home_icon, 26, "Home"),
mapp(BottomNavBarIcon.map_icon, 20, "Map"),
parkings(IParkingIcons.directions_car, 19, "Parkings"),
faculties(BottomNavBarIcon.faculty_icon, 26, "Faculties"),
sciCircles(BottomNavBarIcon.sci_circle_icon, 20, "Scientific Circles"),
info(BottomNavBarIcon.info_icon, 20, "Info");
buildings(BottomNavBarIcon.map_icon, 20, "Map"),
parkings(ParkingsIcons.directions_car, 19, "Parkings"),
departments(BottomNavBarIcon.faculty_icon, 26, "Faculties"),
scienceClubs(BottomNavBarIcon.sci_circle_icon, 20, "Science Clubs"),
guide(BottomNavBarIcon.info_icon, 20, "Info");

const NavBarEnum(this.icon, this.size, this.label);

Expand All @@ -28,11 +28,11 @@ enum NavBarEnum {
abstract class NavBarConfig {
static const tabViews = UnmodifiableNavBarEnumMap(
home: HomeRoute(),
mapp: BuildingMapRoute(),
parkings: ParkingsMapRoute(),
faculties: DepartmentRoute(),
sciCircles: ScientificCirclesRoute(),
info: GuideRouteTemplate(),
buildings: BuildingsRoute(),
parkings: ParkingsRoute(),
departments: DepartmentsRoute(),
scienceClubs: ScienceClubsRoute(),
guide: GuideRoute(),
);
}

Expand Down
3 changes: 0 additions & 3 deletions lib/config/transitions.dart
Original file line number Diff line number Diff line change
Expand Up @@ -3,9 +3,6 @@ import "package:auto_route/auto_route.dart";
// TODO(simon-the-shark): adjust this settings if desired
abstract class TransitionsConfig {
static const durationInMiliseconds = 200;
static const detailDurationInMiliseconds = 200;
static const slideLeftBuilder = TransitionsBuilders.slideLeftWithFade;
static const slideRightBuilder = TransitionsBuilders.slideRightWithFade;
static const fallbackBuilder = TransitionsBuilders.fadeIn;
static const detailViewBuilder = TransitionsBuilders.slideBottom;
}
20 changes: 10 additions & 10 deletions lib/config/ttl_config.dart
Original file line number Diff line number Diff line change
Expand Up @@ -6,15 +6,15 @@ part "ttl_config.g.dart";
@unmodifiableEnumMap
enum TtlKey {
/// We need unique key for every data source for its ttl tracking
sciCirclesPreviewRepository,
academicCalendarRepository,
infosPreviewRepository,
sciCirclesRepository,
newsRepository,
scienceClubsRepository,
scienceClubDetailsRepository,
tagsRepository,
mapBuildingsRepository,
departmentsRepository,
departmentDetailsRepository,
aboutUsRepository,
departmentsDetailsRepository,
buildingsRepository,
// ... add a new key here if you create a new repository
}

Expand All @@ -26,15 +26,15 @@ abstract class TtlStrategy {

static const _ttlDurations = UnmodifiableTtlKeyMap(
// TODO(simon-the-shark): specific values are yet ment to be accordingly adjusted.
infosPreviewRepository: day,
newsRepository: day,
academicCalendarRepository: day,
sciCirclesPreviewRepository: thirtyDays,
sciCirclesRepository: thirtyDays,
scienceClubDetailsRepository: thirtyDays,
scienceClubsRepository: thirtyDays,
tagsRepository: thirtyDays,
mapBuildingsRepository: thirtyDays,
buildingsRepository: thirtyDays,
departmentsRepository: thirtyDays,
aboutUsRepository: thirtyDays,
departmentsDetailsRepository: thirtyDays,
departmentDetailsRepository: thirtyDays,
);

static Duration get(TtlKey key) {
Expand Down
18 changes: 9 additions & 9 deletions lib/config/ui_config.dart
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import "package:flutter/material.dart";

import "../features/iparking_chart/utils/range_hour_points.dart";
import "../features/parking_chart/utils/range_hour_points.dart";
import "../theme/hex_color.dart";

abstract class MyAppConfig {
Expand All @@ -24,7 +24,7 @@ abstract class DepartmentsConfig {

static const listSeparatorSize = 16.0;

static const departmentsTabGridDelegate =
static const departmentsViewGridDelegate =
SliverGridDelegateWithMaxCrossAxisExtent(
maxCrossAxisExtent: 600,
mainAxisExtent: 92,
Expand All @@ -37,7 +37,7 @@ abstract class DateChipConfig {
static const dateTimeFormat = "dd.MM.yyyy";
}

abstract class HomeScreenConfig {
abstract class HomeViewConfig {
static const paddingSmall = 6.0;
static const paddingMedium = 16.0;

Expand All @@ -55,7 +55,7 @@ abstract class BigPreviewCardConfig {
static const cardWidth = 240.0;
}

abstract class SearchWidgetConfig {
abstract class SearchBoxConfig {
static const height = 36.0;
}

Expand All @@ -77,15 +77,15 @@ abstract class WideTileCardConfig {
];
}

abstract class DetailsScreenConfig {
abstract class DetailViewsConfig {
static const double spacerHeight = 16;
}

abstract class DetailsScreenHeaderConfig {
abstract class DetailViewsHeaderConfig {
static const double logoSize = 130;
}

abstract class ScientificCirclesTabConfig {
abstract class ScienceClubsViewConfig {
static const listSeparatorSize = 16.0;
static const microPadding = 4.0;
static const smallPadding = 16.0;
Expand All @@ -109,11 +109,11 @@ abstract class ScientificCirclesTabConfig {
);
}

abstract class ScientificCircleCardConfig {
abstract class ScienceClubCardConfig {
static const trailingPadding = 2.0;
}

abstract class IParkingConfig {
abstract class ParkingsConfig {
static const padding = EdgeInsets.only(
left: 13,
top: 10,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,27 +2,27 @@ import "package:auto_route/auto_route.dart";
import "package:flutter/material.dart";
import "package:flutter_riverpod/flutter_riverpod.dart";

import "../../../../api_base/directus_assets_url.dart";
import "../../../../config/ui_config.dart";
import "../../../../theme/app_theme.dart";
import "../../../../utils/context_extensions.dart";
import "../../../../widgets/details_screen_sliver_header_section.dart";
import "../../../../widgets/my_error_widget.dart";
import "../../../study_circle_details/widgets/details_screen_app_bar.dart";
import "../../api_base/directus_assets_url.dart";
import "../../config/ui_config.dart";
import "../../theme/app_theme.dart";
import "../../utils/context_extensions.dart";
import "../../widgets/detail_views/detail_view_app_bar.dart";
import "../../widgets/detail_views/sliver_header_section.dart";
import "../../widgets/my_error_widget.dart";
import "repository/about_us_repository.dart";
import "widgets/contact_section.dart";
import "widgets/desription_section.dart";
import "widgets/links_section.dart";
import "widgets/section_header.dart";
import "widgets/team_section.dart";

@RoutePage()
class AboutUsTab extends StatelessWidget {
const AboutUsTab({super.key});
class AboutUsView extends StatelessWidget {
const AboutUsView({super.key});

@override
Widget build(BuildContext context) {
return Scaffold(
appBar: DetailsScreenAppBar(context, title: context.localize.guide),
appBar: DetailViewAppBar(context, title: context.localize.guide),
body: const _AboutUsView(),
);
}
Expand Down Expand Up @@ -61,7 +61,7 @@ class _AboutUsView extends ConsumerWidget {
members: value?.getMemberData() ?? [],
),
SectionHeader(text: context.localize.follow_solvro),
LinksSection(
ContactSection(
links: value?.getSocialIcons() ?? [],
),
const SizedBox(
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import "../../../../../api_base/directus_assets_url.dart";
import "../../../api_base/directus_assets_url.dart";

import "../../../../../utils/determine_icon.dart";
import "../../../../../utils/where_non_null_iterable.dart";
import "../../../utils/determine_contact_icon.dart";
import "../../../utils/where_non_null_iterable.dart";
import "../repository/about_us_repository.dart";
import "member_data.dart";

Expand All @@ -22,10 +22,10 @@ class AboutUsDetails {
}).toList();
}

List<UrlIconsModel> getSocialIcons() {
List<ContactIconsModel> getSocialIcons() {
return aboutUs?.solvroSocialLinks.whereNonNull
.map(
(e) => UrlIconsModel(url: e.url),
(e) => ContactIconsModel(url: e.url),
)
.toList() ??
[];
Expand Down
Original file line number Diff line number Diff line change
@@ -1,13 +1,13 @@
import "package:flutter/foundation.dart";

import "../../../../../utils/determine_icon.dart";
import "../../../utils/determine_contact_icon.dart";

@immutable
class MemberData {
final List<String> socialLinks;
final String? name;
final String? subtitle;
final List<UrlIconsModel> links;
final List<ContactIconsModel> links;
final String? imageUrl;

MemberData({
Expand All @@ -17,8 +17,8 @@ class MemberData {
required this.imageUrl,
}) : links = _determineLinksIcons(socialLinks);

static List<UrlIconsModel> _determineLinksIcons(List<String> urls) {
return urls.map((url) => UrlIconsModel(url: url)).toList();
static List<ContactIconsModel> _determineLinksIcons(List<String> urls) {
return urls.map((url) => ContactIconsModel(url: url)).toList();
}

@override
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import "package:riverpod_annotation/riverpod_annotation.dart";

import "../../../../../api_base/watch_query_adapter.dart";
import "../../../../../config/ttl_config.dart";
import "../../../api_base/watch_query_adapter.dart";
import "../../../config/ttl_config.dart";
import "../models/about_us_details.dart";
import "getAboutUsDetails.graphql.dart";

Expand All @@ -14,9 +14,7 @@ typedef AboutUsTeam = Query$getAbousUsDetails$AboutUs_Team;
@riverpod
Stream<AboutUsDetails?> aboutUsRepository(AboutUsRepositoryRef ref) async* {
final stream = ref.watchQueryWithCache(
_GetAboutUs(
eagerlyFetchResults: true,
),
_GetAboutUs(eagerlyFetchResults: true),
TtlKey.aboutUsRepository,
);
yield* stream.map((event) {
Expand Down
Loading