Skip to content

Commit

Permalink
Seventh Version
Browse files Browse the repository at this point in the history
  • Loading branch information
yulieth9109 committed Dec 11, 2023
1 parent efd1d9f commit 28f1572
Show file tree
Hide file tree
Showing 9 changed files with 187 additions and 208 deletions.
2 changes: 1 addition & 1 deletion lib/models/changeset_info_generator.dart
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ import 'dart:ui';

import 'package:latlong2/latlong.dart';

import '/api/offline_geocoder.g.dart';
import "/api/offline_geocoder.g.dart";
import '/commons/country_language_map.dart';
import 'element_variants/base_element.dart';
import 'map_features/map_features.dart';
Expand Down
308 changes: 147 additions & 161 deletions lib/screens/home.dart
Original file line number Diff line number Diff line change
Expand Up @@ -47,180 +47,166 @@ class HomeScreen extends View<HomeViewModel> with PromptHandler {
actionText: request.actionLabel,
actionCallback: request.action,
),
child: Stack(
children: [
Semantics(
label: viewModel.hasQuestionnaire
? appLocale.semanticsReturnToMap
: appLocale.semanticsFlutterMap,
child: FlutterMap(
mapController: viewModel.mapController,
options: MapOptions(
onTap: (_, __) => viewModel.closeQuestionnaire(),
interactionOptions: const InteractionOptions(
enableMultiFingerGestureRace: true,
),
initialCenter: untracked(() => viewModel.storedMapLocation),
initialZoom: untracked(() => viewModel.storedMapZoom),
initialRotation: untracked(() => viewModel.storedMapRotation),
minZoom: kTileLayerPublicTransport.minZoom.toDouble(),
maxZoom: kTileLayerPublicTransport.maxZoom.toDouble(),
backgroundColor: Theme.of(context).colorScheme.background,
child: Semantics(
container: true,
sortKey: const OrdinalSortKey(2.0, name: 'mapLayer'),
label: viewModel.hasQuestionnaire
? appLocale.semanticsReturnToMap
: appLocale.semanticsFlutterMap,
child: FlutterMap(
mapController: viewModel.mapController,
options: MapOptions(
onTap: (_, __) => viewModel.closeQuestionnaire(),
interactionOptions: const InteractionOptions(
enableMultiFingerGestureRace: true,
),
initialCenter: untracked(() => viewModel.storedMapLocation),
initialZoom: untracked(() => viewModel.storedMapZoom),
initialRotation: untracked(() => viewModel.storedMapRotation),
minZoom: kTileLayerPublicTransport.minZoom.toDouble(),
maxZoom: kTileLayerPublicTransport.maxZoom.toDouble(),
backgroundColor: Theme.of(context).colorScheme.background,
),
children: [
TileLayer(
tileProvider: NetworkTileProvider(
headers: {
'User-Agent': appUserAgent,
},
),
children: [
TileLayer(
tileProvider: NetworkTileProvider(
headers: {
'User-Agent': appUserAgent,
retinaMode: RetinaMode.isHighDensity(context),
evictErrorTileStrategy: EvictErrorTileStrategy.dispose,
urlTemplate: isDarkMode && kTileLayerPublicTransport.darkVariantTemplateUrl != null
? kTileLayerPublicTransport.darkVariantTemplateUrl
: kTileLayerPublicTransport.templateUrl,
minNativeZoom: kTileLayerPublicTransport.minZoom,
maxNativeZoom: kTileLayerPublicTransport.maxZoom,
),
Observer(
builder: (context) {
// "length" used to listen to changes
viewModel.loadingStopAreas.length;
return LoadingAreaLayer(
areas: viewModel.loadingStopAreas,
);
},
),
Observer(
builder: (context) {
// "length" used to listen to changes
viewModel.completeStopAreas.length;
return CompletedAreaLayer(
currentZoom: viewModel.mapZoomRound,
locations: viewModel.completeStopAreas.map((s) => s.stops.first.location),
);
},
),
Observer(
builder: (context) {
// "length" used to listen to changes
viewModel
..unloadedStopAreas.length
..incompleteStopAreas.length
..completeStopAreas.length;

return StopsLayer(
currentZoom: viewModel.mapZoomRound,
unloadedStops: viewModel.unloadedStopAreas.map((s) => s.stops.first.location),
incompleteStops: viewModel.incompleteStopAreas.map((s) => s.stops.first.location),
completedStops: viewModel.completeStopAreas.map((s) => s.stops.first.location),
);
},
),
Observer(
builder: (context) {
return AnimatedSwitcher(
duration: const Duration(milliseconds: 300),
child: (viewModel.hasSelectedElement)
? GeometryLayer(
geometry: viewModel.selectedElement!.geometry,
key: viewModel.selectedElementKey,
)
: null,
);
},
),
Observer(
builder: (context) {
// rebuild location indicator when location access is granted
viewModel.userLocationState;
return const AnimatedLocationLayer();
},
),
Semantics(
container: true,
sortKey: const OrdinalSortKey(1.0, name: 'mapLayer'),child:
BlockSemantics(
blocking: viewModel.hasQuestionnaire,
child: Stack(
children: [
// PERHAPS REQUIRES RE-ORDERING
Observer(
builder: (context) {
return OsmElementLayer(
elements: viewModel.elements,
currentZoom: viewModel.mapZoomRound,
onOsmElementTap: viewModel.onElementTap,
selectedElement: viewModel.selectedElement,
);
},
),
retinaMode: RetinaMode.isHighDensity(context),
evictErrorTileStrategy: EvictErrorTileStrategy.dispose,
urlTemplate: isDarkMode && kTileLayerPublicTransport.darkVariantTemplateUrl != null
? kTileLayerPublicTransport.darkVariantTemplateUrl
: kTileLayerPublicTransport.templateUrl,
minNativeZoom: kTileLayerPublicTransport.minZoom,
maxNativeZoom: kTileLayerPublicTransport.maxZoom,
),
Observer(
builder: (context) {
// "length" used to listen to changes
viewModel.loadingStopAreas.length;
return LoadingAreaLayer(
areas: viewModel.loadingStopAreas,
);
},
),
Observer(
builder: (context) {
// "length" used to listen to changes
viewModel.completeStopAreas.length;
return CompletedAreaLayer(
currentZoom: viewModel.mapZoomRound,
locations: viewModel.completeStopAreas.map((s) => s.stops.first.location),
);
},
),
Observer(
builder: (context) {
// "length" used to listen to changes
viewModel
..unloadedStopAreas.length
..incompleteStopAreas.length
..completeStopAreas.length;

return StopsLayer(
currentZoom: viewModel.mapZoomRound,
unloadedStops: viewModel.unloadedStopAreas.map((s) => s.stops.first.location),
incompleteStops: viewModel.incompleteStopAreas.map((s) => s.stops.first.location),
completedStops: viewModel.completeStopAreas.map((s) => s.stops.first.location),
);
},
),
Observer(
builder: (context) {
return AnimatedSwitcher(
RepaintBoundary(
child: AnimatedSwitcher(
switchInCurve: Curves.ease,
switchOutCurve: Curves.ease,
duration: const Duration(milliseconds: 300),
child: (viewModel.hasSelectedElement)
? GeometryLayer(
geometry: viewModel.selectedElement!.geometry,
key: viewModel.selectedElementKey,
)
child: !viewModel.hasQuestionnaire
? const MapOverlay()
: null,
);
},
),
Observer(
builder: (context) {
// rebuild location indicator when location access is granted
viewModel.userLocationState;
return const AnimatedLocationLayer();
},
),
Observer(
builder: (context) {
return OsmElementLayer(
elements: viewModel.elements,
currentZoom: viewModel.mapZoomRound,
onOsmElementTap: viewModel.onElementTap,
selectedElement: viewModel.selectedElement,
);
},
),
RepaintBoundary(
child: AnimatedSwitcher(
switchInCurve: Curves.ease,
switchOutCurve: Curves.ease,
duration: const Duration(milliseconds: 300),
child: !viewModel.hasQuestionnaire
? const MapOverlay()
: null,
),
),
),
],
),
),
// place sheet on extra stack above map so map pan events won't pass through
Observer(
builder: (context) {
return AnimatedSwitcher(
duration: const Duration(milliseconds: 500),
reverseDuration: const Duration(milliseconds: 300),
switchInCurve: Curves.easeInOutCubicEmphasized,
switchOutCurve: Curves.ease,
transitionBuilder: (child, animation) {
final offsetAnimation = Tween<Offset>(
begin: const Offset(0, 1),
end: Offset.zero,
).animate(animation);
return SlideTransition(
position: offsetAnimation,
child: FadeTransition(
opacity: animation,
child: child,
)
);
},
child: viewModel.hasQuestionnaire
? BlockSemantics(
child: Stack(
children: [
Semantics(
sortKey: const OrdinalSortKey(2.0, name: 'QuestionSheet'),
child: Visibility(
visible: false,
maintainState: true,
maintainSemantics: true,
maintainSize: true,
maintainAnimation: true,
maintainInteractivity: true,
child: ModalBarrier(
onDismiss: () => viewModel.closeQuestionnaire(),
semanticsLabel: appLocale.semanticsCloseNavigationMenuButton,
),
),
),
Semantics(
sortKey: const OrdinalSortKey(1.0, name: 'QuestionSheet'),
child: QuestionDialog(

// WILL PROBABLY REQUIRE ABSORBING POINTERS to solve comment below
// place sheet on extra stack above map so map pan events won't pass through
Observer(
builder: (context) {
return AnimatedSwitcher(
duration: const Duration(milliseconds: 500),
reverseDuration: const Duration(milliseconds: 300),
switchInCurve: Curves.easeInOutCubicEmphasized,
switchOutCurve: Curves.ease,
transitionBuilder: (child, animation) {
final offsetAnimation = Tween<Offset>(
begin: const Offset(0, 1),
end: Offset.zero,
).animate(animation);
return SlideTransition(
position: offsetAnimation,
child: FadeTransition(
opacity: animation,
child: child,
)
);
},
child: viewModel.hasQuestionnaire
? QuestionDialog(
activeQuestionIndex: viewModel.currentQuestionnaireIndex!,
questions: viewModel.questionnaireQuestions,
answers: viewModel.questionnaireAnswers,
showSummary: viewModel.questionnaireIsFinished,
key: viewModel.selectedElementKey,
),),
]
),
)
: null
);
},
),
],
)
: null
);
},
),
]
),
),
),],
),
),
),
),
);
}
}
}
13 changes: 0 additions & 13 deletions lib/widgets/home_sidebar/home_sidebar.dart
Original file line number Diff line number Diff line change
Expand Up @@ -60,19 +60,6 @@ class HomeSidebar extends ViewFragment<HomeViewModel> {
title: appLocale.helpTitle,
onTap: () => Navigator.push(context, Routes.help),
),
Visibility(
visible: false,
maintainState: true,
maintainSemantics: true,
maintainSize: true,
maintainAnimation: true,
maintainInteractivity: true,
child: CustomListTile(
leadingIcon: Icons.arrow_back,
title: appLocale.semanticsCloseNavigationMenuButton,
onTap: () => Navigator.pop(context),
),
),
],
),
);
Expand Down
4 changes: 0 additions & 4 deletions lib/widgets/map_overlay/zoom_button.dart
Original file line number Diff line number Diff line change
Expand Up @@ -26,8 +26,6 @@ class ZoomButton extends StatelessWidget {
child: Column(
children: [
Semantics(
container: true,
sortKey: const OrdinalSortKey(1.0, name: 'ZoomButton'),
child: SizedBox(
height: (Theme.of(context).floatingActionButtonTheme.smallSizeConstraints?.minHeight ?? 48.0) * 1.25,
width: Theme.of(context).floatingActionButtonTheme.smallSizeConstraints?.minWidth ?? 48.0,
Expand All @@ -47,8 +45,6 @@ class ZoomButton extends StatelessWidget {
color: Theme.of(context).colorScheme.onPrimaryContainer.withOpacity(0.1),
),
Semantics(
container: true,
sortKey: const OrdinalSortKey(2.0, name: 'ZoomButton'),
child: SizedBox(
height: (Theme.of(context).floatingActionButtonTheme.smallSizeConstraints?.minHeight ?? 48.0) * 1.25,
width: Theme.of(context).floatingActionButtonTheme.smallSizeConstraints?.minWidth ?? 48.0,
Expand Down
2 changes: 1 addition & 1 deletion lib/widgets/osm_element_layer/osm_element_marker.dart
Original file line number Diff line number Diff line change
Expand Up @@ -61,9 +61,9 @@ class _OsmElementMarkerState extends State<OsmElementMarker> with SingleTickerPr
// add repaint boundary for performance improvement
// this way a marker will only be redrawn if itself changes
return Semantics(
label: widget.label,
excludeSemantics: widget.active ? true : false,
blockUserActions: widget.active ? true : false,
label: widget.active ? null : widget.label,
child: RepaintBoundary(
child: Center(
child: GestureDetector(
Expand Down
Loading

0 comments on commit 28f1572

Please sign in to comment.