Skip to content

Commit ced5ff9

Browse files
committed
Add InspirationScreen to display counting ideas and integrate with HomeScreen
1 parent b4241af commit ced5ff9

2 files changed

Lines changed: 115 additions & 0 deletions

File tree

lib/screens/home_screen.dart

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,7 @@ import '../utils/utils.dart';
1717
import '../widgets/accept_cancel_dialog.dart';
1818
import '../widgets/counter_display.dart';
1919
import '../widgets/counters_drawer.dart';
20+
import 'inspiration_screen.dart';
2021
import 'settings_screen.dart';
2122

2223
/// Overflow menu items enumeration.
@@ -142,6 +143,14 @@ class _HomeScreenState extends State<HomeScreen> {
142143
return AppBar(
143144
title: Text(_counters.current.name),
144145
actions: <Widget>[
146+
IconButton(
147+
icon: const Icon(Icons.lightbulb_outline),
148+
tooltip: 'Inspiration',
149+
onPressed: () => utils.navigateToScreen(
150+
context,
151+
InspirationScreen(counter: _counters.current),
152+
),
153+
),
145154
PopupMenuButton<MenuAction>(
146155
onSelected: popupMenuSelection,
147156
itemBuilder: _buildMenuItems,
Lines changed: 106 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,106 @@
1+
// Copyright 2020-2025 The Hello World Writer. All rights reserved.
2+
// https://www.thehelloworldwriter.com
3+
//
4+
// Use of this source code is governed by an MIT-style license
5+
// that can be found in the LICENSE file.
6+
7+
import 'package:flutter/material.dart';
8+
9+
import '../data/counter_ideas.dart';
10+
import '../models/counter.dart';
11+
import '../utils/utils.dart';
12+
13+
/// Screen that displays inspiration ideas for counting with a specific counter color.
14+
class InspirationScreen extends StatelessWidget {
15+
const InspirationScreen({required this.counter, super.key});
16+
17+
final Counter counter;
18+
19+
@override
20+
Widget build(BuildContext context) {
21+
final List<String> ideas = counterIdeas[counter.type] ?? [];
22+
final Color counterColor = counter.color;
23+
final Color textColor = counterColor.contrastOf();
24+
final String colorName = counter.type.name[0].toUpperCase() + counter.type.name.substring(1);
25+
26+
return Scaffold(
27+
appBar: AppBar(
28+
title: Text('$colorName Inspiration'),
29+
backgroundColor: counterColor,
30+
foregroundColor: textColor,
31+
iconTheme: IconThemeData(color: textColor),
32+
),
33+
body: ideas.isEmpty ? _buildEmptyState(colorName) : _buildIdeasList(ideas, counterColor),
34+
);
35+
}
36+
37+
/// Builds the empty state when no ideas are available.
38+
Widget _buildEmptyState(String colorName) {
39+
return Center(
40+
child: Padding(
41+
padding: const EdgeInsets.all(32.0),
42+
child: Column(
43+
mainAxisAlignment: MainAxisAlignment.center,
44+
children: [
45+
Icon(
46+
Icons.lightbulb_outline,
47+
size: 64,
48+
color: Colors.grey[400],
49+
),
50+
const SizedBox(height: 16),
51+
Text(
52+
'No inspiration ideas yet for $colorName.',
53+
textAlign: TextAlign.center,
54+
style: TextStyle(
55+
fontSize: 18,
56+
color: Colors.grey[600],
57+
),
58+
),
59+
const SizedBox(height: 8),
60+
Text(
61+
'Use this counter for anything you\'d like!',
62+
textAlign: TextAlign.center,
63+
style: TextStyle(
64+
fontSize: 16,
65+
color: Colors.grey[500],
66+
),
67+
),
68+
],
69+
),
70+
),
71+
);
72+
}
73+
74+
/// Builds the list of counting ideas.
75+
Widget _buildIdeasList(List<String> ideas, Color counterColor) {
76+
return ListView(
77+
padding: const EdgeInsets.symmetric(vertical: 16),
78+
children: [
79+
// Header text
80+
Padding(
81+
padding: const EdgeInsets.fromLTRB(16, 8, 16, 16),
82+
child: Text(
83+
'Running out of ideas? Try counting these:',
84+
style: TextStyle(
85+
fontSize: 14,
86+
color: Colors.grey[600],
87+
fontStyle: FontStyle.italic,
88+
),
89+
),
90+
),
91+
// Ideas list
92+
...ideas.map(
93+
(idea) => ListTile(
94+
leading: Icon(
95+
Icons.circle,
96+
size: 12,
97+
color: counterColor,
98+
),
99+
title: Text(idea),
100+
visualDensity: VisualDensity.comfortable,
101+
),
102+
),
103+
],
104+
);
105+
}
106+
}

0 commit comments

Comments
 (0)