Skip to content

Commit ba0bfaf

Browse files
Merge pull request SimformSolutionsPvtLtd#3 from simformsolutions/feature/title_optional
Tooltip title made optional
2 parents 03a6961 + 5ff9c61 commit ba0bfaf

File tree

3 files changed

+35
-23
lines changed

3 files changed

+35
-23
lines changed

example/lib/main.dart

Lines changed: 16 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -57,8 +57,7 @@ class _MailPageState extends State<MailPage> {
5757
children: <Widget>[
5858
Showcase(
5959
key: _one,
60-
title: 'Menu',
61-
description: 'Click here to see menu options',
60+
description: 'Tap to see menu options',
6261
child: Icon(
6362
Icons.menu,
6463
color: Colors.black45,
@@ -80,7 +79,7 @@ class _MailPageState extends State<MailPage> {
8079
Showcase(
8180
key: _two,
8281
title: 'Profile',
83-
description: 'Click here to go to your Profile',
82+
description: 'Tap to see profile',
8483
showcaseBackgroundColor : Colors.blueAccent,
8584
textColor: Colors.white,
8685
shapeBorder: CircleBorder(),
@@ -118,12 +117,14 @@ class _MailPageState extends State<MailPage> {
118117
),
119118
],
120119
),
120+
121+
Padding(padding: EdgeInsets.only(top: 8)),
122+
121123
Container(
122-
padding: const EdgeInsets.symmetric(vertical: 10),
124+
padding: const EdgeInsets.symmetric(vertical: 8),
123125
child: Showcase(
124126
key: _three,
125-
title: 'Mail',
126-
description: 'Click here to check mail',
127+
description: 'Tap to check mail',
127128
child: Container(
128129
padding: const EdgeInsets.only(left: 6, right: 16),
129130
child: Row(
@@ -142,8 +143,8 @@ class _MailPageState extends State<MailPage> {
142143
crossAxisAlignment: CrossAxisAlignment.start,
143144
children: <Widget>[
144145
Container(
145-
width: 40,
146-
height: 40,
146+
width: 45,
147+
height: 45,
147148
decoration: BoxDecoration(
148149
shape: BoxShape.circle,
149150
color: Colors.blue[200],
@@ -164,8 +165,8 @@ class _MailPageState extends State<MailPage> {
164165
child: Container(
165166
margin: const EdgeInsets.all(10),
166167
child: Container(
167-
width: 40,
168-
height: 40,
168+
width: 45,
169+
height: 45,
169170
decoration: BoxDecoration(
170171
shape: BoxShape.circle,
171172
color: Colors.blue[200],
@@ -176,6 +177,7 @@ class _MailPageState extends State<MailPage> {
176177
),
177178
),
178179
),
180+
Padding(padding: EdgeInsets.only(left: 8)),
179181
Column(
180182
crossAxisAlignment: CrossAxisAlignment.start,
181183
children: <Widget>[
@@ -314,7 +316,7 @@ class MailTile extends StatelessWidget {
314316
@override
315317
Widget build(BuildContext context) {
316318
return Container(
317-
padding: const EdgeInsets.only(left: 6, right: 16, top: 8),
319+
padding: const EdgeInsets.only(left: 6, right: 16, top: 8,bottom: 8),
318320
child: Row(
319321
crossAxisAlignment: CrossAxisAlignment.start,
320322
children: <Widget>[
@@ -324,8 +326,8 @@ class MailTile extends StatelessWidget {
324326
children: <Widget>[
325327
Container(
326328
margin: const EdgeInsets.all(10),
327-
width: 40,
328-
height: 40,
329+
width: 45,
330+
height: 45,
329331
decoration: BoxDecoration(
330332
shape: BoxShape.circle,
331333
color: Colors.blue[200],
@@ -334,6 +336,7 @@ class MailTile extends StatelessWidget {
334336
child: Text(mail.sender[0]),
335337
),
336338
),
339+
Padding(padding: EdgeInsets.only(left: 8)),
337340
Column(
338341
crossAxisAlignment: CrossAxisAlignment.start,
339342
children: <Widget>[

lib/showcase.dart

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,7 @@ class Showcase extends StatefulWidget {
2727
const Showcase({
2828
@required this.key,
2929
@required this.child,
30-
@required this.title,
30+
this.title,
3131
@required this.description,
3232
this.shapeBorder,
3333
this.overlayColor,
@@ -157,7 +157,7 @@ class _ShowcaseState extends State<Showcase> with TickerProviderStateMixin {
157157
height: MediaQuery.of(context).size.height,
158158
child: CustomPaint(
159159
painter: ShapePainter(
160-
opacity: widget.overlayOpacity ?? 0.7,
160+
opacity: widget.overlayOpacity ?? 0.75,
161161
rect: position.getRect(),
162162
shapeBorder: widget.shapeBorder,
163163
color: widget.overlayColor ?? Colors.black),

lib/tooltip_widget.dart

Lines changed: 17 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -52,7 +52,7 @@ class ToolTipWidget extends StatelessWidget {
5252
}
5353

5454
double _getTooltipWidth() {
55-
double titleLength = (title.length * 10.0);
55+
double titleLength = title == null ? 0 : (title.length * 10.0);
5656
double descriptionLength = (description.length * 7.0);
5757
if (titleLength > descriptionLength) {
5858
return titleLength + 10;
@@ -163,17 +163,26 @@ class ToolTipWidget extends StatelessWidget {
163163
children: <Widget>[
164164
Container(
165165
child: Column(
166-
crossAxisAlignment: CrossAxisAlignment.start,
166+
crossAxisAlignment: title != null ? CrossAxisAlignment.start : CrossAxisAlignment.center,
167167
children: <Widget>[
168-
Text(
169-
title,
170-
style: titleTextStyle ??
171-
Theme.of(context).textTheme.title.merge(TextStyle(color: textColor)),
172-
),
168+
title != null
169+
? Text(
170+
title,
171+
style: titleTextStyle ??
172+
Theme.of(context)
173+
.textTheme
174+
.title
175+
.merge(TextStyle(
176+
color: textColor)),
177+
)
178+
: Container(),
173179
Text(
174180
description,
175181
style: descTextStyle ??
176-
Theme.of(context).textTheme.subtitle.merge(TextStyle(color: textColor)),
182+
Theme.of(context)
183+
.textTheme
184+
.subtitle
185+
.merge(TextStyle(color: textColor)),
177186
),
178187
],
179188
),

0 commit comments

Comments
 (0)