Skip to content

Commit

Permalink
Changed the way the offset is calculated in function on the shape of …
Browse files Browse the repository at this point in the history
…the target

Fix for RafaelBarbosatec#6
  • Loading branch information
Vanethos committed Jul 17, 2019
1 parent a7288cf commit c9958c6
Show file tree
Hide file tree
Showing 4 changed files with 42 additions and 27 deletions.
6 changes: 6 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -8,3 +8,9 @@ build/
ios/.generated/
ios/Flutter/Generated.xcconfig
ios/Runner/GeneratedPluginRegistrant.*

# IntelliJ related
*.iml
*.ipr
*.iws
.idea/
2 changes: 1 addition & 1 deletion example/pubspec.lock
Original file line number Diff line number Diff line change
Expand Up @@ -127,7 +127,7 @@ packages:
path: ".."
relative: true
source: path
version: "0.1.1"
version: "0.2.0"
typed_data:
dependency: transitive
description:
Expand Down
47 changes: 28 additions & 19 deletions lib/tutorial_coach_mark_widget.dart
Original file line number Diff line number Diff line change
Expand Up @@ -19,15 +19,15 @@ class TutorialCoachMarkWidget extends StatefulWidget {
final String textSkip;
const TutorialCoachMarkWidget(
{Key key,
this.targets,
this.finish,
this.paddingFocus = 10,
this.clickTarget,
this.alignSkip = Alignment.bottomRight,
this.textSkip = "SKIP",
this.clickSkip,
this.colorShadow = Colors.black,
this.opacityShadow = 0.8})
this.targets,
this.finish,
this.paddingFocus = 10,
this.clickTarget,
this.alignSkip = Alignment.bottomRight,
this.textSkip = "SKIP",
this.clickSkip,
this.colorShadow = Colors.black,
this.opacityShadow = 0.8})
: super(key: key);

@override
Expand Down Expand Up @@ -100,10 +100,19 @@ class _TutorialCoachMarkWidgetState extends State<TutorialCoachMarkWidget> {
TargetPosition target = getTargetCurrent(currentTarget);
var positioned = Offset(target.offset.dx + target.size.width / 2,
target.offset.dy + target.size.height / 2);
var sizeCircle = target.size.width > target.size.height
? target.size.width
: target.size.height;
sizeCircle = sizeCircle * 0.6 + widget.paddingFocus;
double haloWidth;
double haloHeight;
if (currentTarget.shape == ShapeLightFocus.Circle) {
haloWidth = target.size.width > target.size.height
? target.size.width
: target.size.height;
haloHeight = haloWidth;
} else {
haloWidth = target.size.width;
haloHeight = target.size.height;
}
haloWidth = haloWidth * 0.6 + widget.paddingFocus;
haloHeight = haloHeight * 0.6 + widget.paddingFocus;
double weight = 0.0;

double top;
Expand All @@ -116,7 +125,7 @@ class _TutorialCoachMarkWidgetState extends State<TutorialCoachMarkWidget> {
{
weight = MediaQuery.of(context).size.width;
left = 0;
top = positioned.dy + sizeCircle;
top = positioned.dy + haloHeight;
bottom = null;
}
break;
Expand All @@ -125,22 +134,22 @@ class _TutorialCoachMarkWidgetState extends State<TutorialCoachMarkWidget> {
weight = MediaQuery.of(context).size.width;
left = 0;
top = null;
bottom = sizeCircle +
bottom = haloHeight +
(MediaQuery.of(context).size.height - positioned.dy);
}
break;
case AlignContent.left:
{
weight = positioned.dx - sizeCircle;
weight = positioned.dx - haloWidth;
left = 0;
top = positioned.dy - target.size.height / 2 - sizeCircle;
top = positioned.dy - target.size.height / 2 - haloHeight;
bottom = null;
}
break;
case AlignContent.right:
{
left = positioned.dx + sizeCircle;
top = positioned.dy - target.size.height / 2 - sizeCircle;
left = positioned.dx + haloWidth;
top = positioned.dy - target.size.height / 2 - haloHeight;
bottom = null;
weight = MediaQuery.of(context).size.width - left;
}
Expand Down
14 changes: 7 additions & 7 deletions pubspec.lock
Original file line number Diff line number Diff line change
@@ -1,20 +1,20 @@
# Generated by pub
# See https://www.dartlang.org/tools/pub/glossary#lockfile
# See https://dart.dev/tools/pub/glossary#lockfile
packages:
async:
dependency: transitive
description:
name: async
url: "https://pub.dartlang.org"
source: hosted
version: "2.1.0"
version: "2.2.0"
boolean_selector:
dependency: transitive
description:
name: boolean_selector
url: "https://pub.dartlang.org"
source: hosted
version: "1.0.4"
version: "1.0.5"
charcode:
dependency: transitive
description:
Expand Down Expand Up @@ -66,14 +66,14 @@ packages:
name: pedantic
url: "https://pub.dartlang.org"
source: hosted
version: "1.5.0"
version: "1.8.0+1"
quiver:
dependency: transitive
description:
name: quiver
url: "https://pub.dartlang.org"
source: hosted
version: "2.0.2"
version: "2.0.3"
sky_engine:
dependency: transitive
description: flutter
Expand Down Expand Up @@ -120,7 +120,7 @@ packages:
name: test_api
url: "https://pub.dartlang.org"
source: hosted
version: "0.2.4"
version: "0.2.5"
typed_data:
dependency: transitive
description:
Expand All @@ -136,4 +136,4 @@ packages:
source: hosted
version: "2.0.8"
sdks:
dart: ">=2.2.0 <3.0.0"
dart: ">=2.2.2 <3.0.0"

0 comments on commit c9958c6

Please sign in to comment.