Skip to content
This repository has been archived by the owner on Jun 13, 2024. It is now read-only.

Make some text selectable and add mouse cursors to clickable things #539

Merged
merged 6 commits into from
Sep 22, 2021
Merged
Show file tree
Hide file tree
Changes from 1 commit
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
8 changes: 4 additions & 4 deletions lib/pages/about.dart
Original file line number Diff line number Diff line change
Expand Up @@ -54,14 +54,14 @@ class _AboutDialog extends StatelessWidget {
children: [
FutureBuilder(
future: getVersionNumber(),
builder: (context, snapshot) => Text(
builder: (context, snapshot) => SelectableText(
snapshot.hasData ? '$name ${snapshot.data}' : name,
style: textTheme.headline4.apply(color: colorScheme.onPrimary),
),
),
const SizedBox(height: 24),
RichText(
text: TextSpan(
SelectableText.rich(
TextSpan(
children: [
TextSpan(
style: bodyTextStyle,
Expand Down Expand Up @@ -91,7 +91,7 @@ class _AboutDialog extends StatelessWidget {
),
),
const SizedBox(height: 18),
Text(
SelectableText(
legalese,
style: bodyTextStyle,
),
Expand Down
9 changes: 3 additions & 6 deletions lib/pages/demo.dart
Original file line number Diff line number Diff line change
Expand Up @@ -672,7 +672,7 @@ class _DemoSectionInfo extends StatelessWidget {
crossAxisAlignment: CrossAxisAlignment.start,
mainAxisSize: MainAxisSize.min,
children: [
Text(
SelectableText(
title,
style: textTheme.headline4.apply(
color: colorScheme.onSurface,
Expand All @@ -681,7 +681,7 @@ class _DemoSectionInfo extends StatelessWidget {
),
),
const SizedBox(height: 12),
Text(
SelectableText(
description,
style: textTheme.bodyText2.apply(color: colorScheme.onSurface),
),
Expand Down Expand Up @@ -827,10 +827,7 @@ class CodeDisplayPage extends StatelessWidget {
child: SingleChildScrollView(
child: Container(
padding: const EdgeInsets.symmetric(vertical: 8),
child: RichText(
textDirection: TextDirection.ltr,
guidezpl marked this conversation as resolved.
Show resolved Hide resolved
text: _richTextCode,
),
child: SelectableText.rich(_richTextCode),
),
),
),
Expand Down
6 changes: 2 additions & 4 deletions lib/pages/home.dart
Original file line number Diff line number Diff line change
Expand Up @@ -295,7 +295,7 @@ class Header extends StatelessWidget {
top: isDisplayDesktop(context) ? 63 : 15,
bottom: isDisplayDesktop(context) ? 21 : 11,
),
child: Text(
child: SelectableText(
text,
style: Theme.of(context).textTheme.headline4.apply(
color: color,
Expand Down Expand Up @@ -564,13 +564,11 @@ class _DesktopCategoryHeader extends StatelessWidget {
padding: const EdgeInsetsDirectional.only(start: 8),
child: Semantics(
header: true,
child: Text(
child: SelectableText(
category.displayTitle(GalleryLocalizations.of(context)),
style: Theme.of(context).textTheme.headline5.apply(
color: colorScheme.onSurface,
),
maxLines: 4,
overflow: TextOverflow.ellipsis,
guidezpl marked this conversation as resolved.
Show resolved Hide resolved
),
),
),
Expand Down
2 changes: 1 addition & 1 deletion lib/pages/settings.dart
Original file line number Diff line number Diff line change
Expand Up @@ -352,7 +352,7 @@ class SettingsAttribution extends StatelessWidget {
top: verticalPadding,
bottom: verticalPadding,
),
child: Text(
child: SelectableText(
GalleryLocalizations.of(context).settingsAttribution,
style: Theme.of(context).textTheme.bodyText1.copyWith(
fontSize: 12,
Expand Down
2 changes: 1 addition & 1 deletion lib/pages/settings_list_item.dart
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@ class SlowMotionSetting extends StatelessWidget {
crossAxisAlignment: CrossAxisAlignment.start,
mainAxisAlignment: MainAxisAlignment.center,
children: [
Text(
SelectableText(
GalleryLocalizations.of(context).settingsSlowMotion,
style: textTheme.subtitle1.apply(
color: colorScheme.onSurface,
Expand Down
2 changes: 1 addition & 1 deletion lib/studies/crane/backdrop.dart
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,7 @@ class _FrontLayerState extends State<_FrontLayer> {
top: 20,
bottom: 22,
),
child: Text(
child: SelectableText(
widget.title,
style: Theme.of(context).textTheme.subtitle2,
),
Expand Down
10 changes: 5 additions & 5 deletions lib/studies/crane/item_cards.dart
Original file line number Diff line number Diff line change
Expand Up @@ -37,12 +37,12 @@ class DestinationCard extends StatelessWidget {
),
Padding(
padding: const EdgeInsets.only(top: 20, bottom: 10),
child: Text(
child: SelectableText(
destination.destination,
style: textTheme.subtitle1,
),
),
Text(
SelectableText(
destination.subtitle(context),
semanticsLabel: destination.subtitleSemantics(context),
style: textTheme.subtitle2,
Expand All @@ -64,9 +64,9 @@ class DestinationCard extends StatelessWidget {
child: _DestinationImage(destination: destination),
),
),
title:
Text(destination.destination, style: textTheme.subtitle1),
subtitle: Text(
title: SelectableText(destination.destination,
style: textTheme.subtitle1),
subtitle: SelectableText(
destination.subtitle(context),
semanticsLabel: destination.subtitleSemantics(context),
style: textTheme.subtitle2,
Expand Down
41 changes: 21 additions & 20 deletions lib/studies/fortnightly/shared.dart
Original file line number Diff line number Diff line change
Expand Up @@ -45,20 +45,20 @@ class HorizontalArticlePreview extends StatelessWidget {
child: Column(
crossAxisAlignment: CrossAxisAlignment.start,
children: [
Text(
SelectableText(
data.category,
style: textTheme.subtitle1,
),
const SizedBox(height: 12),
Text(
SelectableText(
data.title,
style: textTheme.headline5.copyWith(fontSize: 16),
),
],
),
),
if (minutes != null) ...[
Text(
SelectableText(
GalleryLocalizations.of(context).craneMinutes(minutes),
style: textTheme.bodyText1,
),
Expand Down Expand Up @@ -122,18 +122,18 @@ class VerticalArticlePreview extends StatelessWidget {
),
),
const SizedBox(height: 12),
Text(
SelectableText(
data.category,
style: textTheme.subtitle1,
),
const SizedBox(height: 12),
Text(
SelectableText(
data.title,
style: headlineTextStyle ?? textTheme.headline5,
),
if (showSnippet) ...[
const SizedBox(height: 4),
Text(
SelectableText(
data.snippet,
style: textTheme.bodyText2,
),
Expand Down Expand Up @@ -190,7 +190,7 @@ List<Widget> buildArticlePreviewItems(BuildContext context) {
),
),
sectionDivider,
Text(
SelectableText(
GalleryLocalizations.of(context).fortnightlyLatestUpdates,
style: textTheme.headline6,
),
Expand Down Expand Up @@ -253,35 +253,35 @@ class HashtagBar extends StatelessWidget {
children: [
const SizedBox(width: 16),
Center(
child: Text(
child: SelectableText(
'#${GalleryLocalizations.of(context).fortnightlyTrendingTechDesign}',
style: textTheme.subtitle2,
),
),
verticalDivider,
Center(
child: Text(
child: SelectableText(
'#${GalleryLocalizations.of(context).fortnightlyTrendingReform}',
style: textTheme.subtitle2,
),
),
verticalDivider,
Center(
child: Text(
child: SelectableText(
'#${GalleryLocalizations.of(context).fortnightlyTrendingHealthcareRevolution}',
style: textTheme.subtitle2,
),
),
verticalDivider,
Center(
child: Text(
child: SelectableText(
'#${GalleryLocalizations.of(context).fortnightlyTrendingGreenArmy}',
style: textTheme.subtitle2,
),
),
verticalDivider,
Center(
child: Text(
child: SelectableText(
'#${GalleryLocalizations.of(context).fortnightlyTrendingStocks}',
style: textTheme.subtitle2,
),
Expand Down Expand Up @@ -354,7 +354,7 @@ class MenuItem extends StatelessWidget {
child: header ? null : const Icon(Icons.arrow_drop_down),
),
Expanded(
child: Text(
child: SelectableText(
title,
style: Theme.of(context).textTheme.subtitle1.copyWith(
fontWeight: header ? FontWeight.w700 : FontWeight.w600,
Expand Down Expand Up @@ -387,19 +387,19 @@ class StockItem extends StatelessWidget {
return Column(
crossAxisAlignment: CrossAxisAlignment.start,
children: [
Text(ticker, style: textTheme.subtitle1),
SelectableText(ticker, style: textTheme.subtitle1),
const SizedBox(height: 2),
Row(
children: [
Expanded(
child: Text(
child: SelectableText(
price,
style: textTheme.subtitle2.copyWith(
color: textTheme.subtitle2.color.withOpacity(0.75),
),
),
),
Text(
SelectableText(
percent > 0 ? '+' : '-',
style: textTheme.subtitle2.copyWith(
fontSize: 12,
Expand All @@ -409,7 +409,7 @@ class StockItem extends StatelessWidget {
),
),
const SizedBox(width: 4),
Text(
SelectableText(
percentFormat.format(percent.abs() / 100),
style: textTheme.caption.copyWith(
fontSize: 12,
Expand Down Expand Up @@ -521,13 +521,14 @@ class VideoPreview extends StatelessWidget {
Row(
children: [
Expanded(
child: Text(data.category, style: textTheme.subtitle1),
child: SelectableText(data.category, style: textTheme.subtitle1),
),
Text(time, style: textTheme.bodyText1)
SelectableText(time, style: textTheme.bodyText1)
],
),
const SizedBox(height: 4),
Text(data.title, style: textTheme.headline5.copyWith(fontSize: 16)),
SelectableText(data.title,
style: textTheme.headline5.copyWith(fontSize: 16)),
],
);
}
Expand Down
2 changes: 1 addition & 1 deletion lib/studies/rally/charts/pie_chart.dart
Original file line number Diff line number Diff line change
Expand Up @@ -182,7 +182,7 @@ class _AnimatedRallyPieChart extends AnimatedWidget {
centerLabel,
style: labelTextStyle,
),
Text(
SelectableText(
usdWithSignFormat(context).format(centerAmount),
style: headlineStyle,
),
Expand Down
74 changes: 38 additions & 36 deletions lib/studies/rally/login.dart
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,6 @@ class _LoginPageState extends State<LoginPage> with RestorationMixin {
Widget build(BuildContext context) {
return ApplyTextOptions(
child: Scaffold(
appBar: AppBar(automaticallyImplyLeading: false),
guidezpl marked this conversation as resolved.
Show resolved Hide resolved
body: SafeArea(
child: _MainView(
usernameController: _usernameController.value,
Expand Down Expand Up @@ -293,42 +292,45 @@ class _ThumbButtonState extends State<_ThumbButton> {
button: true,
enabled: true,
label: GalleryLocalizations.of(context).rallyLoginLabelLogin,
child: GestureDetector(
onTap: widget.onTap,
child: Focus(
onKey: (node, event) {
if (event is RawKeyDownEvent) {
if (event.logicalKey == LogicalKeyboardKey.enter ||
event.logicalKey == LogicalKeyboardKey.space) {
widget.onTap();
return KeyEventResult.handled;
child: MouseRegion(
cursor: SystemMouseCursors.click,
child: GestureDetector(
onTap: widget.onTap,
child: Focus(
onKey: (node, event) {
if (event is RawKeyDownEvent) {
if (event.logicalKey == LogicalKeyboardKey.enter ||
event.logicalKey == LogicalKeyboardKey.space) {
widget.onTap();
return KeyEventResult.handled;
}
}
}
return KeyEventResult.ignored;
},
onFocusChange: (hasFocus) {
if (hasFocus) {
setState(() {
borderDecoration = BoxDecoration(
border: Border.all(
color: Colors.white.withOpacity(0.5),
width: 2,
),
);
});
} else {
setState(() {
borderDecoration = null;
});
}
},
child: Container(
decoration: borderDecoration,
height: 120,
child: ExcludeSemantics(
child: Image.asset(
'thumb.png',
package: 'rally_assets',
return KeyEventResult.ignored;
},
onFocusChange: (hasFocus) {
if (hasFocus) {
setState(() {
borderDecoration = BoxDecoration(
border: Border.all(
color: Colors.white.withOpacity(0.5),
width: 2,
),
);
});
} else {
setState(() {
borderDecoration = null;
});
}
},
child: Container(
decoration: borderDecoration,
height: 120,
child: ExcludeSemantics(
child: Image.asset(
'thumb.png',
package: 'rally_assets',
),
),
),
),
Expand Down
Loading