Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Remove the deprecated ignoringSemantics and use new ExcludeSemantics Widget #128

Open
wants to merge 2 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
Expand Up @@ -27,39 +27,41 @@ class _BottomTextContent extends StatelessWidget {
Gap($styles.insets.md),
Column(
children: [
IgnorePointer(
ignoringSemantics: false,
child: Semantics(
button: true,
onIncrease: () => state._handleArtifactTap(_currentPage + 1),
onDecrease: () => state._handleArtifactTap(_currentPage - 1),
onTap: () => state._handleArtifactTap(_currentPage),
liveRegion: true,
child: Column(
mainAxisAlignment: MainAxisAlignment.start,
children: [
// Force column to stretch horizontally so text is centered
SizedBox(width: double.infinity),
// Stop text from scaling to make layout a little easier, it's already quite large
StaticTextScale(
child: Text(
artifact.title,
overflow: TextOverflow.ellipsis,
style: $styles.text.h2.copyWith(color: $styles.colors.black, height: 1.2, fontSize: 32),
textAlign: TextAlign.center,
maxLines: 2,
ExcludeSemantics(
excluding: false,
child: IgnorePointer(
child: Semantics(
button: true,
onIncrease: () => state._handleArtifactTap(_currentPage + 1),
onDecrease: () => state._handleArtifactTap(_currentPage - 1),
onTap: () => state._handleArtifactTap(_currentPage),
liveRegion: true,
child: Column(
mainAxisAlignment: MainAxisAlignment.start,
children: [
// Force column to stretch horizontally so text is centered
SizedBox(width: double.infinity),
// Stop text from scaling to make layout a little easier, it's already quite large
StaticTextScale(
child: Text(
artifact.title,
overflow: TextOverflow.ellipsis,
style: $styles.text.h2.copyWith(color: $styles.colors.black, height: 1.2, fontSize: 32),
textAlign: TextAlign.center,
maxLines: 2,
),
),
),
if (!shortMode) ...[
Gap($styles.insets.xxs),
Text(
artifact.date.isEmpty ? '--' : artifact.date,
style: $styles.text.body,
textAlign: TextAlign.center,
),
]
],
).animate(key: ValueKey(artifact.artifactId)).fadeIn(),
if (!shortMode) ...[
Gap($styles.insets.xxs),
Text(
artifact.date.isEmpty ? '--' : artifact.date,
style: $styles.text.body,
textAlign: TextAlign.center,
),
]
],
).animate(key: ValueKey(artifact.artifactId)).fadeIn(),
),
),
),
],
Expand Down
56 changes: 29 additions & 27 deletions lib/ui/screens/home/wonders_home_screen.dart
Expand Up @@ -262,33 +262,35 @@ class _HomeScreenState extends State<HomeScreen> with SingleTickerProviderStateM

/// Title Content
LightText(
child: IgnorePointer(
ignoringSemantics: false,
child: Transform.translate(
offset: Offset(0, 30),
child: Column(
children: [
Semantics(
liveRegion: true,
button: true,
header: true,
onIncrease: () => _setPageIndex(_wonderIndex + 1),
onDecrease: () => _setPageIndex(_wonderIndex - 1),
onTap: () => _showDetailsPage(),
// Hide the title when the menu is open for visual polish
child: WonderTitleText(currentWonder, enableShadows: true),
),
Gap($styles.insets.md),
AppPageIndicator(
count: _numWonders,
controller: _pageController,
color: $styles.colors.white,
dotSize: 8,
onDotPressed: _handlePageIndicatorDotPressed,
semanticPageTitle: $strings.homeSemanticWonder,
),
Gap($styles.insets.md),
],
child: ExcludeSemantics(
excluding: false,
child: IgnorePointer(
child: Transform.translate(
offset: Offset(0, 30),
child: Column(
children: [
Semantics(
liveRegion: true,
button: true,
header: true,
onIncrease: () => _setPageIndex(_wonderIndex + 1),
onDecrease: () => _setPageIndex(_wonderIndex - 1),
onTap: () => _showDetailsPage(),
// Hide the title when the menu is open for visual polish
child: WonderTitleText(currentWonder, enableShadows: true),
),
Gap($styles.insets.md),
AppPageIndicator(
count: _numWonders,
controller: _pageController,
color: $styles.colors.white,
dotSize: 8,
onDotPressed: _handlePageIndicatorDotPressed,
semanticPageTitle: $strings.homeSemanticWonder,
),
Gap($styles.insets.md),
],
),
),
),
),
Expand Down
4 changes: 1 addition & 3 deletions lib/ui/screens/home_menu/about_dialog_content.dart
@@ -1,5 +1,4 @@
import 'package:flutter/cupertino.dart';
import 'package:flutter/foundation.dart';
import 'package:flutter/gestures.dart';
import 'package:url_launcher/url_launcher.dart';
import 'package:wonders/common_libs.dart';
Expand All @@ -12,12 +11,11 @@ class AboutDialogContent extends StatelessWidget {
@override
Widget build(BuildContext context) {
void handleTap(String url) {
if(PlatformInfo.isDesktopOrWeb){
if (PlatformInfo.isDesktopOrWeb) {
launchUrl(Uri.parse(url));
} else {
Navigator.push(context, CupertinoPageRoute(builder: (_) => FullscreenWebView(url)));
}

}

List<TextSpan> buildSpan(String text, {Map<String, List<String>>? linkSupplants}) {
Expand Down
92 changes: 47 additions & 45 deletions lib/ui/screens/intro/intro_screen.dart
@@ -1,7 +1,7 @@
import 'package:flutter/gestures.dart';
import 'package:flutter_svg/flutter_svg.dart';
import 'package:wonders/common_libs.dart';
import 'package:wonders/ui/common/app_icons.dart';
import 'package:wonders/ui/common/app_icons.dart';
import 'package:wonders/ui/common/controls/app_page_indicator.dart';
import 'package:wonders/ui/common/gradient_container.dart';
import 'package:wonders/ui/common/static_text_scale.dart';
Expand Down Expand Up @@ -53,14 +53,14 @@ class _IntroScreenState extends State<IntroScreen> {

void _handleNavTextSemanticTap() => _incrementPage(1);

void _incrementPage(int dir){
void _incrementPage(int dir) {
final int current = _pageController.page!.round();
if (_isOnLastPage && dir > 0) return;
if (_isOnFirstPage && dir < 0) return;
_pageController.animateToPage(current + dir, duration: 250.ms, curve: Curves.easeIn);
}

void _handleScrollWheel(double delta) => _incrementPage(delta >0? 1 : -1);
void _handleScrollWheel(double delta) => _incrementPage(delta > 0 ? 1 : -1);

@override
Widget build(BuildContext context) {
Expand All @@ -79,8 +79,8 @@ class _IntroScreenState extends State<IntroScreen> {

/// Return resulting widget tree
return Listener(
onPointerSignal: (signal){
if(signal is PointerScrollEvent){
onPointerSignal: (signal) {
if (signal is PointerScrollEvent) {
_handleScrollWheel(signal.scrollDelta.dy);
}
},
Expand All @@ -107,52 +107,54 @@ class _IntroScreenState extends State<IntroScreen> {
),
),

IgnorePointer(
ignoringSemantics: false,
child: Column(children: [
Spacer(),

// logo:
Semantics(
header: true,
child: Container(
height: _logoHeight,
alignment: Alignment.center,
child: _WonderousLogo(),
ExcludeSemantics(
excluding: false,
child: IgnorePointer(
child: Column(children: [
Spacer(),

// logo:
Semantics(
header: true,
child: Container(
height: _logoHeight,
alignment: Alignment.center,
child: _WonderousLogo(),
),
),
),

// masked image:
SizedBox(
height: _imageSize,
width: _imageSize,
child: ValueListenableBuilder<int>(
valueListenable: _currentPage,
builder: (_, value, __) {
return AnimatedSwitcher(
duration: $styles.times.slow,
child: KeyedSubtree(
key: ValueKey(value), // so AnimatedSwitcher sees it as a different child.
child: _PageImage(data: pageData[value]),
),
);
},
// masked image:
SizedBox(
height: _imageSize,
width: _imageSize,
child: ValueListenableBuilder<int>(
valueListenable: _currentPage,
builder: (_, value, __) {
return AnimatedSwitcher(
duration: $styles.times.slow,
child: KeyedSubtree(
key: ValueKey(value), // so AnimatedSwitcher sees it as a different child.
child: _PageImage(data: pageData[value]),
),
);
},
),
),
),

// placeholder gap for text:
Gap(_IntroScreenState._textHeight),
// placeholder gap for text:
Gap(_IntroScreenState._textHeight),

// page indicator:
Container(
height: _pageIndicatorHeight,
alignment: Alignment(0.0, 0),
child: AppPageIndicator(
count: pageData.length, controller: _pageController, color: $styles.colors.offWhite),
),
// page indicator:
Container(
height: _pageIndicatorHeight,
alignment: Alignment(0.0, 0),
child: AppPageIndicator(
count: pageData.length, controller: _pageController, color: $styles.colors.offWhite),
),

Spacer(flex: 2),
]),
Spacer(flex: 2),
]),
),
),

// Build a cpl overlays to hide the content when swiping on very wide screens
Expand Down
64 changes: 33 additions & 31 deletions lib/ui/screens/timeline/widgets/_event_markers.dart
Expand Up @@ -55,41 +55,43 @@ class _EventMarkersState extends State<_EventMarkers> {

@override
Widget build(BuildContext context) {
return IgnorePointer(
ignoringSemantics: false,
child: LayoutBuilder(builder: (_, constraints) {
/// Figure out which event is "selected"
_updateSelectedEvent(constraints.maxHeight);
return ExcludeSemantics(
excluding: false,
child: IgnorePointer(
child: LayoutBuilder(builder: (_, constraints) {
/// Figure out which event is "selected"
_updateSelectedEvent(constraints.maxHeight);

/// Create a marker for each event
List<Widget> markers = timelineLogic.events.map((event) {
double offsetY = _calculateOffsetY(event.year);
return _EventMarker(
offsetY,
event: event,
isSelected: event == selectedEvent,
onPressed: widget.onMarkerPressed,
);
}).toList();
/// Create a marker for each event
List<Widget> markers = timelineLogic.events.map((event) {
double offsetY = _calculateOffsetY(event.year);
return _EventMarker(
offsetY,
event: event,
isSelected: event == selectedEvent,
onPressed: widget.onMarkerPressed,
);
}).toList();

/// Stack of fractionally positioned markers
return FocusTraversalGroup(
policy: WidgetOrderTraversalPolicy(),
child: Container(
alignment: Alignment.topLeft,
padding: EdgeInsets.only(left: 75),
child: SizedBox(
width: 20,
child: Stack(
children: [
...markers,
if (showReferenceMarkers) ..._buildReferenceMarkers(),
],
/// Stack of fractionally positioned markers
return FocusTraversalGroup(
policy: WidgetOrderTraversalPolicy(),
child: Container(
alignment: Alignment.topLeft,
padding: EdgeInsets.only(left: 75),
child: SizedBox(
width: 20,
child: Stack(
children: [
...markers,
if (showReferenceMarkers) ..._buildReferenceMarkers(),
],
),
),
),
),
);
}),
);
}),
),
);
}

Expand Down