Skip to content

Commit

Permalink
merge: pull request #118 from Solvro/refactor/navigation-remake
Browse files Browse the repository at this point in the history
  • Loading branch information
simon-the-shark authored Aug 3, 2024
2 parents 189eee0 + 46a9e89 commit e419a3b
Show file tree
Hide file tree
Showing 169 changed files with 1,364 additions and 1,302 deletions.
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -145,6 +145,7 @@ app.*.symbols
*.graphql.dart
*.tailor.dart
*.gen.dart
*.gr.dart



Expand Down
2 changes: 2 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -143,6 +143,8 @@ 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)
6. For navigation we use `auto_route`, docs here: https://pub.dev/packages/auto_route

# 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
41 changes: 35 additions & 6 deletions lib/config/nav_bar_config.dart
Original file line number Diff line number Diff line change
@@ -1,23 +1,52 @@
import "package:auto_route/auto_route.dart";
import "package:collection/collection.dart";
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);

final IconData icon;
final double size;
final String label;
}

abstract class NavBarConfig {
static const tabViews = UnmodifiableNavBarEnumMap(
home: HomeRoute(),
buildings: BuildingsRoute(),
parkings: ParkingsRoute(),
departments: DepartmentsRoute(),
scienceClubs: ScienceClubsRoute(),
guide: GuideRoute(),
);
}

extension IsRouteATabViewOnStringX on String {
NavBarEnum? get tabBarEnum => NavBarConfig.tabViews.entries
.firstWhereOrNull((entry) => entry.value.routeName == this)
?.key;

bool get isTabView =>
NavBarConfig.tabViews.values.map((i) => i.routeName).contains(this);
}

extension IsRouteATabViewX on PageRouteInfo<dynamic> {
NavBarEnum? get tabBarEnum => routeName.tabBarEnum;

bool get isTabView => routeName.isTabView;
}
22 changes: 0 additions & 22 deletions lib/config/navigator_config.dart

This file was deleted.

8 changes: 0 additions & 8 deletions lib/config/routes.dart

This file was deleted.

8 changes: 8 additions & 0 deletions lib/config/transitions.dart
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
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 slideLeftBuilder = TransitionsBuilders.slideLeftWithFade;
static const slideRightBuilder = TransitionsBuilders.slideRightWithFade;
}
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
@@ -1,26 +1,28 @@
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";

class AboutUsTab extends StatelessWidget {
const AboutUsTab({super.key});
@RoutePage()
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 @@ -59,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
Loading

0 comments on commit e419a3b

Please sign in to comment.