Skip to content

Commit fc3fffe

Browse files
committed
Add clipboard copy functionality and improve text styling in InspirationScreen
1 parent 8c5a3fc commit fc3fffe

3 files changed

Lines changed: 19 additions & 6 deletions

File tree

.vscode/settings.json

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,5 +14,4 @@
1414
],
1515
},
1616
"dart.lineLength": 100,
17-
"dart.mcpServer": true,
1817
}

lib/common/strings.dart

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -49,6 +49,7 @@ String inspirationScreenTitle(String name) => '$name Inspiration';
4949
const String inspirationHeader = 'Running out of ideas? Try counting these:';
5050
String noInspirationTitle(String name) => 'No inspiration ideas yet for $name.';
5151
const String noInspirationSubtitle = 'Use this counter for anything you\'d like!';
52+
const String ideaCopied = 'Idea copied to clipboard!';
5253

5354
// -----------------------------------------------------------------------------
5455
// Settings Screen

lib/screens/inspiration_screen.dart

Lines changed: 18 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -5,11 +5,12 @@
55
// that can be found in the LICENSE file.
66

77
import 'package:flutter/material.dart';
8+
import 'package:flutter/services.dart';
89

910
import '../common/strings.dart' as strings;
1011
import '../data/counter_ideas.dart';
1112
import '../models/counter.dart';
12-
import '../utils/utils.dart';
13+
import '../utils/utils.dart' as utils;
1314

1415
/// Screen that displays inspiration ideas for counting with a specific counter color.
1516
class InspirationScreen extends StatefulWidget {
@@ -74,13 +75,16 @@ class _EmptyStateWidget extends StatelessWidget {
7475
Text(
7576
strings.noInspirationTitle(colorName),
7677
textAlign: TextAlign.center,
77-
style: TextStyle(fontSize: 18, color: Colors.grey[600]),
78+
style: Theme.of(context).textTheme.titleLarge?.copyWith(
79+
fontSize: 18.0,
80+
color: Colors.grey[600],
81+
),
7882
),
7983
const SizedBox(height: 8),
8084
Text(
8185
strings.noInspirationSubtitle,
8286
textAlign: TextAlign.center,
83-
style: TextStyle(fontSize: 16, color: Colors.grey[500]),
87+
style: Theme.of(context).textTheme.bodyLarge?.copyWith(color: Colors.grey[500]),
8488
),
8589
],
8690
),
@@ -112,7 +116,10 @@ class _IdeasListWidget extends StatelessWidget {
112116
padding: const EdgeInsets.fromLTRB(16, 8, 16, 16),
113117
child: Text(
114118
strings.inspirationHeader,
115-
style: TextStyle(fontSize: 14, color: Colors.grey[600], fontStyle: FontStyle.italic),
119+
style: Theme.of(context).textTheme.bodyMedium?.copyWith(
120+
color: Colors.grey[600],
121+
fontStyle: FontStyle.italic,
122+
),
116123
),
117124
),
118125
// Ideas list
@@ -135,17 +142,23 @@ class _IdeaListItem extends StatelessWidget {
135142
/// The color of the leading dot.
136143
final Color dotColor;
137144

145+
/// Handles long press to copy the idea to clipboard.
146+
void _onLongPress(BuildContext context) {
147+
Clipboard.setData(ClipboardData(text: idea));
148+
utils.showSnackBar(context, strings.ideaCopied);
149+
}
150+
138151
@override
139152
Widget build(BuildContext context) {
140153
return ListTile(
141154
visualDensity: .comfortable,
142-
// visualDensity: .compact,
143155
minLeadingWidth: 20.0,
144156
leading: Icon(Icons.circle, size: 12.0, color: dotColor),
145157
title: Text(
146158
idea,
147159
style: Theme.of(context).textTheme.bodyMedium?.copyWith(fontSize: 15.0),
148160
),
161+
onLongPress: () => _onLongPress(context),
149162
);
150163
}
151164
}

0 commit comments

Comments
 (0)