Skip to content

Commit

Permalink
merge: branch 'main' into 198-feat-add-proper-deep-links--app-links (…
Browse files Browse the repository at this point in the history
…catch up with main)
  • Loading branch information
simon-the-shark committed Sep 19, 2024
2 parents 26fa58c + 2634063 commit 69832ca
Show file tree
Hide file tree
Showing 39 changed files with 112 additions and 150 deletions.
9 changes: 7 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
# ToPWR

![ToPWR file cover](/assets/topwr_header.png)
![ToPWR file cover](/assets/png/topwr_header.png)

## 🇵🇱

Expand Down Expand Up @@ -133,7 +133,11 @@ dart run build_runner build -d
flutter run
```

5. **[OPTIONAL]** If you operate on many Flutter versions, I reccomend to you `fvm` Flutter version manager: https://fvm.app/
5. ### SVGO
For SVG files optimization we use `svg_optimizer` (which uses SVGO under the hood) that's why before you start you need to install [Node.js](https://nodejs.org/en/download/package-manager) and [SVGO optimization tool](https://svgo.dev/docs/introduction/) on your machine
6. **[OPTIONAL]** If you operate on many Flutter versions, I reccomend to you `fvm` Flutter version manager: https://fvm.app/
```bash
fvm dart run build_runner watch
fvm flutter run
Expand All @@ -149,6 +153,7 @@ fvm flutter run
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
7. For SVG files optimization we use `svg_optimizer` (which uses SVGO under the hood), related article here: https://www.thedroidsonroids.com/blog/svg-open-source-flutter-package

# Before you push a commit
- run the linter
Expand Down
File renamed without changes
File renamed without changes
File renamed without changes
File renamed without changes
File renamed without changes
File renamed without changes
File renamed without changes
File renamed without changes
File renamed without changes
File renamed without changes
File renamed without changes
File renamed without changes
File renamed without changes
File renamed without changes
File renamed without changes
File renamed without changes
File renamed without changes
File renamed without changes
File renamed without changes
File renamed without changes
File renamed without changes
24 changes: 12 additions & 12 deletions lib/config/contact_icons.dart
Original file line number Diff line number Diff line change
Expand Up @@ -2,17 +2,17 @@ import "../gen/assets.gen.dart";

abstract class ContactIconsConfig {
static final iconsPaths = {
"facebook": Assets.contactIcons.fb,
"instagram": Assets.contactIcons.ig,
"linkedin": Assets.contactIcons.linkedin,
"mailto:": Assets.contactIcons.mail,
"youtu": Assets.contactIcons.yt,
"github": Assets.contactIcons.github,
"topwr:buildings": Assets.contactIcons.compass,
"tel": Assets.contactIcons.phone,
"https://x.com": Assets.contactIcons.x,
"tiktok": Assets.contactIcons.tiktok,
"discord": Assets.contactIcons.discord,
"facebook": Assets.svg.contactIcons.fb,
"instagram": Assets.svg.contactIcons.ig,
"linkedin": Assets.svg.contactIcons.linkedin,
"mailto:": Assets.svg.contactIcons.mail,
"youtu": Assets.svg.contactIcons.yt,
"github": Assets.svg.contactIcons.github,
"topwr:buildings": Assets.svg.contactIcons.compass,
"tel": Assets.svg.contactIcons.phone,
"https://x.com": Assets.svg.contactIcons.x,
"tiktok": Assets.svg.contactIcons.tiktok,
"discord": Assets.svg.contactIcons.discord,
};
static final iconsOrder = {
"maps": 1,
Expand All @@ -28,5 +28,5 @@ abstract class ContactIconsConfig {
"tiktok": 12,
};
static const defaultIconOrder = 2;
static final defaultIcon = Assets.contactIcons.web;
static final defaultIcon = Assets.svg.contactIcons.web;
}
8 changes: 0 additions & 8 deletions lib/config/transitions.dart

This file was deleted.

10 changes: 6 additions & 4 deletions lib/config/ui_config.dart
Original file line number Diff line number Diff line change
Expand Up @@ -53,6 +53,7 @@ abstract class HomeViewConfig {
abstract class BigPreviewCardConfig {
static const cardHeight = 360.0;
static const cardWidth = 240.0;
static const defaultCrossAxisForcedSize = 220.0;
}

abstract class SearchBoxConfig {
Expand Down Expand Up @@ -102,10 +103,10 @@ abstract class ScienceClubsViewConfig {
);

static const tagsGridDelegate = SliverGridDelegateWithMaxCrossAxisExtent(
maxCrossAxisExtent: 100,
mainAxisExtent: 92,
crossAxisSpacing: 8,
mainAxisSpacing: 16,
maxCrossAxisExtent: 85,
mainAxisExtent: 40,
crossAxisSpacing: 4,
mainAxisSpacing: 4,
);
}

Expand Down Expand Up @@ -151,6 +152,7 @@ abstract class GuideViewConfig {
abstract class FilterConfig {
static const bottomSheetHeightFactor = 0.65;
static const searchFilterPadding = 15.0;
static const paddingMedium = 8.0;
}

abstract class LottieAnimationConfig {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,9 @@ class DepartmentDetailViewLoading extends StatelessWidget {
SizedBox(height: DetailViewsConfig.spacerHeight),
ContactSectionLoading(),
SizedBox(height: DetailViewsConfig.spacerHeight),
BigScrollableSectionLoading(),
BigScrollableSectionLoading(
crossAxisForcedSize: 400,
),
],
),
);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,12 +8,15 @@ import "../paddings.dart";
class BigScrollableSectionLoading extends StatelessWidget {
const BigScrollableSectionLoading({
super.key,
this.crossAxisForcedSize = BigPreviewCardConfig.defaultCrossAxisForcedSize,
});

final double crossAxisForcedSize;

@override
Widget build(BuildContext context) {
return ScrollableLoaderBuilder(
crossAxisForcedSize: 220,
crossAxisForcedSize: crossAxisForcedSize,
mainAxisItemSize: BigPreviewCardConfig.cardWidth,
scrollDirection: Axis.horizontal,
itemBuilder: (context, index) {
Expand Down
4 changes: 2 additions & 2 deletions lib/features/home_view/widgets/logo_app_bar.dart
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ class AppBarLogo extends StatelessWidget {
const AppBarLogo({super.key});

static Future<void> precacheImageIfAbsent() async {
const loader = SvgAssetLoader(Assets.logoAppBar);
final loader = SvgAssetLoader(Assets.svg.logoAppBar);
await svg.cache.putIfAbsent(
loader.cacheKey(null),
() => loader.loadBytes(null),
Expand All @@ -35,7 +35,7 @@ class AppBarLogo extends StatelessWidget {
Widget build(BuildContext context) {
return Padding(
padding: const EdgeInsets.symmetric(horizontal: 24, vertical: 48),
child: SvgPicture.asset(Assets.logoAppBar),
child: SvgPicture.asset(Assets.svg.logoAppBar),
);
}
}
8 changes: 4 additions & 4 deletions lib/features/map_view/utils/map_marker_utils.dart
Original file line number Diff line number Diff line change
Expand Up @@ -16,19 +16,19 @@ class MapMarkerUtils {
final activeMarkerConfig = context.activeMapMarkerConfiguration;
buildingMapMarker = await BitmapDescriptor.asset(
configuration,
Assets.mapMarkers.mapMarker.path,
Assets.png.mapMarkers.mapMarker.path,
);
activeBuildingMapMarker = await BitmapDescriptor.asset(
activeMarkerConfig,
Assets.mapMarkers.activeMapMarker.path,
Assets.png.mapMarkers.activeMapMarker.path,
);
parkingMapMarker = await BitmapDescriptor.asset(
configuration,
Assets.mapMarkers.parkingMapMarker.path,
Assets.png.mapMarkers.parkingMapMarker.path,
);
activeParkingMapMarker = await BitmapDescriptor.asset(
activeMarkerConfig,
Assets.mapMarkers.activeParkingMapMarker.path,
Assets.png.mapMarkers.activeParkingMapMarker.path,
);
}
}
Expand Down
52 changes: 16 additions & 36 deletions lib/features/navigator/app_router.dart
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@ import "package:flutter/material.dart";
import "package:flutter_riverpod/flutter_riverpod.dart";
import "package:riverpod_annotation/riverpod_annotation.dart";

import "../../config/transitions.dart";
import "../about_us_view/about_us_view.dart";
import "../buildings_view/buildings_view.dart";
import "../department_detail_view/department_detail_view.dart";
Expand All @@ -15,11 +14,20 @@ import "../parkings_view/parkings_view.dart";
import "../science_club_detail_view/science_club_detail_view.dart";
import "../science_clubs_view/science_clubs_view.dart";
import "root_view.dart";
import "utils/tab_bar_transition.dart";

part "app_router.g.dart";
part "app_router.gr.dart";

class _NoTransitionRoute extends CustomRoute {
_NoTransitionRoute({
required super.path,
required super.page,
}) : super(
reverseDurationInMilliseconds: 0,
durationInMilliseconds: 0,
);
}

@AutoRouterConfig(replaceInRouteName: "View,Route")
class AppRouter extends _$AppRouter {
final Ref ref;
Expand All @@ -32,65 +40,37 @@ class AppRouter extends _$AppRouter {
path: "/",
page: RootRoute.page,
children: [
CustomRoute(
_NoTransitionRoute(
path: "",
page: HomeRoute.page,
durationInMilliseconds: TransitionsConfig.durationInMiliseconds,
reverseDurationInMilliseconds:
TransitionsConfig.durationInMiliseconds,
transitionsBuilder: ref.tabBarTransitionBuilder(HomeRoute.name),
),
CustomRoute(
_NoTransitionRoute(
path: "buildings",
page: BuildingsRoute.page,
durationInMilliseconds: TransitionsConfig.durationInMiliseconds,
reverseDurationInMilliseconds:
TransitionsConfig.durationInMiliseconds,
transitionsBuilder:
ref.tabBarTransitionBuilder(BuildingsRoute.name),
),
CustomRoute(
_NoTransitionRoute(
path: "parkings",
page: ParkingsRoute.page,
durationInMilliseconds: TransitionsConfig.durationInMiliseconds,
reverseDurationInMilliseconds:
TransitionsConfig.durationInMiliseconds,
transitionsBuilder:
ref.tabBarTransitionBuilder(ParkingsRoute.name),
),
CustomRoute(
_NoTransitionRoute(
path: "departments",
page: DepartmentsRoute.page,
durationInMilliseconds: TransitionsConfig.durationInMiliseconds,
reverseDurationInMilliseconds:
TransitionsConfig.durationInMiliseconds,
transitionsBuilder:
ref.tabBarTransitionBuilder(DepartmentsRoute.name),
),
AutoRoute(
path: "departments/:id",
page: DepartmentDetailRoute.page,
),
CustomRoute(
_NoTransitionRoute(
path: "sci-clubs",
page: ScienceClubsRoute.page,
durationInMilliseconds: TransitionsConfig.durationInMiliseconds,
reverseDurationInMilliseconds:
TransitionsConfig.durationInMiliseconds,
transitionsBuilder:
ref.tabBarTransitionBuilder(ScienceClubsRoute.name),
),
AutoRoute(
path: "sci-clubs/:id",
page: ScienceClubDetailRoute.page,
),
CustomRoute(
_NoTransitionRoute(
path: "guide",
page: GuideRoute.page,
durationInMilliseconds: TransitionsConfig.durationInMiliseconds,
reverseDurationInMilliseconds:
TransitionsConfig.durationInMiliseconds,
transitionsBuilder: ref.tabBarTransitionBuilder(GuideRoute.name),
),
AutoRoute(
path: "aboutUs",
Expand Down
12 changes: 4 additions & 8 deletions lib/features/navigator/navigation_controller.dart
Original file line number Diff line number Diff line change
Expand Up @@ -22,29 +22,25 @@ class NavigationController extends _$NavigationController {

StackRouter? get _router => navigatorKey.currentState?.controller;

bool didLastPop = false; // used only for tabbar transition

Iterable<TRoute> get stack =>
Iterable<TRoute> get _stack =>
_router?.stackData.map((e) => e.route.toPageRouteInfo()) ?? [];

Future<void> push(TRoute route) async {
didLastPop = false;
final popFutureResults = _router?.push(route); // push the route
await Future.delayed(
Duration.zero,
refreshState, // refresh the state after the push
);
// await the route's pop
if (popFutureResults != null) await popFutureResults;
didLastPop = true;
refreshState(); // refresh the state after the pop
}

/// this is called only when you actually **click** in the nav tab bar
/// so we don't call this on other navigation actions (like `Lista >` buttons)
Future<void> onTabBarChange(NavBarEnum item) async {
final route = NavBarConfig.tabViews.get(item);
if (stack.last.routeName != route.routeName) {
if (_stack.last.routeName != route.routeName) {
_popUntilTabBarView();
await push(route);
}
Expand All @@ -70,9 +66,9 @@ class NavigationController extends _$NavigationController {
@override
NavigationState build() {
return (
isStackPoppable: stack.length > 1,
isStackPoppable: _stack.length > 1,
activeTab:
stack.lastWhereOrNull((element) => element.isTabView)?.tabBarEnum ??
_stack.lastWhereOrNull((element) => element.isTabView)?.tabBarEnum ??
NavBarEnum.home,
);
}
Expand Down
39 changes: 0 additions & 39 deletions lib/features/navigator/utils/tab_bar_transition.dart

This file was deleted.

11 changes: 8 additions & 3 deletions lib/features/parkings_view/widgets/parking_favourite.dart
Original file line number Diff line number Diff line change
Expand Up @@ -19,27 +19,32 @@ class FavouriteParkingWidget extends ConsumerWidget {
visualDensity: VisualDensity.compact,
onPressed: favController.toggle,
icon: isFavorite == null
? const FavouriteIcon(
? FavouriteIcon(
icon: Icons.error,
color: context.colorTheme.whiteSoap,
)
: FavouriteIcon(
icon: isFavorite
? Icons.favorite_rounded
: Icons.favorite_border_outlined,
color: isFavorite
? context.colorTheme.orangePomegranade
: context.colorTheme.whiteSoap,
),
);
}
}

class FavouriteIcon extends StatelessWidget {
const FavouriteIcon({super.key, required this.icon});
const FavouriteIcon({super.key, required this.icon, required this.color});
final IconData icon;
final Color color;

@override
Widget build(BuildContext context) {
return Icon(
icon,
color: context.colorTheme.whiteSoap,
color: color,
size: 22,
shadows: iparkingShadows,
);
Expand Down
Loading

0 comments on commit 69832ca

Please sign in to comment.