Skip to content

Commit

Permalink
refactor: unife codebase naming
Browse files Browse the repository at this point in the history
  • Loading branch information
simon-the-shark committed Aug 2, 2024
1 parent b30a40e commit 5cd5ef7
Show file tree
Hide file tree
Showing 144 changed files with 754 additions and 777 deletions.
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
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
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/sliver_header_section.dart";
import "../../widgets/detail_views/detail_view_app_bar.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
Original file line number Diff line number Diff line change
@@ -1,22 +1,21 @@
import "package:flutter/material.dart";
// unfortunetly it's a dependency of dependency and it's not re-exported
// ignore: depend_on_referenced_packages
import "package:html/dom.dart" as html;
import "../../../../../theme/app_theme.dart";
import "../../../../../theme/hex_color.dart";

extension ToHtmlColorString on HexColor {
import "../../../theme/app_theme.dart";
import "../../../theme/hex_color.dart";

extension ToHtmlColorStringX on HexColor {
String get htmlFormat =>
'#${value.toRadixString(16).padLeft(8, '0').substring(2)}';
}

extension IsLinkTag on html.Element {
extension IsLinkTagX on html.Element {
bool get isLink {
return localName == "a";
}
}

extension CustomHtmlStyles on BuildContext {
extension CustomHtmlStylesX on BuildContext {
Map<String, String>? customStylesBuilder(html.Element element) {
final defaultStyles = {
"text-align": "justify",
Expand Down
Loading

0 comments on commit 5cd5ef7

Please sign in to comment.