Skip to content
Draft
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
2 changes: 1 addition & 1 deletion packages/uni_app/lib/generated/intl/messages_en.dart
Original file line number Diff line number Diff line change
Expand Up @@ -403,7 +403,7 @@ class MessageLookup extends MessageLookupByLibrary {
"save": MessageLookupByLibrary.simpleMessage("Save"),
"schedule": MessageLookupByLibrary.simpleMessage("Schedule"),
"school_calendar": MessageLookupByLibrary.simpleMessage("School Calendar"),
"search": MessageLookupByLibrary.simpleMessage("Search"),
"search_here": MessageLookupByLibrary.simpleMessage("Search here"),
"see_more": MessageLookupByLibrary.simpleMessage("See more"),
"select_all": MessageLookupByLibrary.simpleMessage("Select All"),
"semester": MessageLookupByLibrary.simpleMessage("Semester"),
Expand Down
2 changes: 1 addition & 1 deletion packages/uni_app/lib/generated/intl/messages_pt_PT.dart
Original file line number Diff line number Diff line change
Expand Up @@ -423,7 +423,7 @@ class MessageLookup extends MessageLookupByLibrary {
"school_calendar": MessageLookupByLibrary.simpleMessage(
"Calendário Escolar",
),
"search": MessageLookupByLibrary.simpleMessage("Pesquisar"),
"search_here": MessageLookupByLibrary.simpleMessage("Pesquisar aqui"),
"see_more": MessageLookupByLibrary.simpleMessage("Ver mais"),
"select_all": MessageLookupByLibrary.simpleMessage("Selecionar Todos"),
"semester": MessageLookupByLibrary.simpleMessage("Semestre"),
Expand Down
6 changes: 3 additions & 3 deletions packages/uni_app/lib/generated/l10n.dart

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion packages/uni_app/lib/l10n/intl_en.arb
Original file line number Diff line number Diff line change
Expand Up @@ -350,7 +350,7 @@
"@year": {},
"see_more": "See more",
"@see_more": {},
"search": "Search",
"search_here": "Search here",
"@search": {},
"confirm_logout": "Do you really want to log out? Your local data will be deleted and you will have to log in again.",
"@confirm_logout": {},
Expand Down
2 changes: 1 addition & 1 deletion packages/uni_app/lib/l10n/intl_pt_PT.arb
Original file line number Diff line number Diff line change
Expand Up @@ -350,7 +350,7 @@
"@widget_prompt": {},
"year": "Ano",
"@year": {},
"search": "Pesquisar",
"search_here": "Pesquisar aqui",
"@search": {},
"confirm_logout": "Tens a certeza de que queres terminar sessão? Os teus dados locais serão apagados e terás de iniciar sessão novamente.",
"@confirm_logout": {},
Expand Down
76 changes: 45 additions & 31 deletions packages/uni_app/lib/view/map/map.dart
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ import 'package:uni/generated/l10n.dart';
import 'package:uni/model/entities/location_group.dart';
import 'package:uni/model/providers/riverpod/default_consumer.dart';
import 'package:uni/model/providers/riverpod/faculty_locations_provider.dart';
import 'package:uni/view/map/widgets/floor_selector.dart';
import 'package:uni/view/map/widgets/floorless_marker_popup.dart';
import 'package:uni/view/map/widgets/marker.dart';
import 'package:uni/view/map/widgets/marker_popup.dart';
Expand All @@ -29,12 +30,14 @@ class MapPageStateView extends ConsumerState<MapPage> {
var _searchTerms = '';
late final PopupController _popupLayerController;
LatLngBounds? _bounds;
int? _selectedFloor;

@override
void initState() {
super.initState();
_searchTerms = '';
_popupLayerController = PopupController();
_selectedFloor = null;
}

@override
Expand Down Expand Up @@ -67,6 +70,16 @@ class MapPageStateView extends ConsumerState<MapPage> {
});
}

if (_selectedFloor != null) {
filteredLocations.retainWhere((location) {
return location.floors.containsKey(_selectedFloor);
});
}

final allFloors =
locations.expand((group) => group.floors.keys).toSet().toList()
..sort((a, b) => b.compareTo(a));

return AnnotatedRegion<SystemUiOverlayStyle>(
value: AppSystemOverlayStyles.base.copyWith(
statusBarIconBrightness: Brightness.dark,
Expand All @@ -82,13 +95,14 @@ class MapPageStateView extends ConsumerState<MapPage> {
minZoom: 16,
maxZoom: 19,
initialCenter: bounds.center,
initialCameraFit: CameraFit.insideBounds(bounds: bounds),
initialZoom: 17,
cameraConstraint: CameraConstraint.containCenter(
bounds: bounds,
),
onTap:
(tapPosition, latlng) =>
_popupLayerController.hideAllPopups(),
onTap: (tapPosition, latlng) {
_popupLayerController.hideAllPopups();
FocusScope.of(context).unfocus();
},
interactionOptions: const InteractionOptions(
flags: InteractiveFlag.all - InteractiveFlag.rotate,
),
Expand Down Expand Up @@ -128,40 +142,33 @@ class MapPageStateView extends ConsumerState<MapPage> {
),
),
),
PopupMarkerLayer(
options: PopupMarkerLayerOptions(
markers:
filteredLocations.map((location) {
return LocationMarker(location.latlng, location);
}).toList(),
popupController: _popupLayerController,
popupDisplayOptions: PopupDisplayOptions(
animation: const PopupAnimation.fade(
duration: Duration(milliseconds: 400),
),
builder: (_, marker) {
if (marker is LocationMarker) {
return marker.locationGroup.isFloorless
? FloorlessLocationMarkerPopup(
marker.locationGroup,
)
: LocationMarkerPopup(marker.locationGroup);
}
return const Card(child: Text(''));
Positioned(
right: 10,
top: 400,
child: SafeArea(
child: FloorSelector(
floors: allFloors,
selectedFloor: _selectedFloor,
onFloorSelected: (floor) {
setState(() {
_selectedFloor = floor;
_popupLayerController.hideAllPopups();
});
},
),
),
),
SafeArea(
child: Padding(
padding: const EdgeInsets.symmetric(
horizontal: 20,
vertical: 10,
padding: const EdgeInsets.only(
left: 10,
right: 10,
top: 12,
),
child: PhysicalModel(
borderRadius: BorderRadius.circular(10),
color: Colors.white,
elevation: 3,
color: const Color(0xFFFFF5F3),
elevation: 4,
child: TextFormField(
key: searchFormKey,
onChanged: (text) {
Expand All @@ -179,15 +186,22 @@ class MapPageStateView extends ConsumerState<MapPage> {
child: SvgPicture.asset(
'assets/images/logo_dark.svg',
semanticsLabel: 'search',
width: 10,
width: 44,
height: 25,
),
),
border: OutlineInputBorder(
borderRadius: BorderRadius.circular(10),
borderSide: BorderSide.none,
),
contentPadding: const EdgeInsets.all(10),
hintText: '${S.of(context).search}...',
hintText: S.of(context).search_here,
hintStyle: const TextStyle(
fontFamily: 'Roboto',
fontSize: 9,
fontWeight: FontWeight.w400,
color: Color(0xFF7F7F7F),
),
),
),
),
Expand Down
57 changes: 57 additions & 0 deletions packages/uni_app/lib/view/map/widgets/floor_selector.dart
Original file line number Diff line number Diff line change
@@ -0,0 +1,57 @@
import 'package:flutter/material.dart';
import 'package:uni_ui/theme.dart';

class FloorSelector extends StatelessWidget {
const FloorSelector({
required this.floors,
required this.selectedFloor,
required this.onFloorSelected,
super.key,
});

final List<int> floors;
final int? selectedFloor;
final void Function(int?) onFloorSelected;

@override
Widget build(BuildContext context) {
return Container(
decoration: BoxDecoration(
color: const Color(0xFFFFF5F3),
borderRadius: BorderRadius.circular(8),
boxShadow: const [BoxShadow(color: Color(0x40000000), blurRadius: 4)],
),
child: Column(
mainAxisSize: MainAxisSize.min,
children:
floors.map((floor) {
final isSelected = selectedFloor == floor;
return InkWell(
onTap: () => onFloorSelected(isSelected ? null : floor),
child: Container(
width: 50,
height: 50,
decoration: BoxDecoration(
borderRadius: BorderRadius.circular(8),
color:
isSelected
? const Color(0x40B14D54)
: Colors.transparent,
),
child: Center(
child: Text(
floor.toString(),
style: TextStyle(
fontSize: 16,
fontWeight: FontWeight.w600,
color: isSelected ? primaryVibrant : grayText,
),
),
),
),
);
}).toList(),
),
);
}
}