-
Notifications
You must be signed in to change notification settings - Fork 22
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
8 changed files
with
197 additions
and
83 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,104 @@ | ||
import 'package:easy_popup/easy_popup.dart'; | ||
import 'package:flutter/material.dart'; | ||
|
||
class GuidePopup extends StatefulWidget with EasyPopupChild { | ||
final List<GlobalKey> highlightKeys; | ||
|
||
GuidePopup(this.highlightKeys); | ||
|
||
@override | ||
_GuidePopupState createState() => _GuidePopupState(); | ||
|
||
@override | ||
dismiss() {} | ||
} | ||
|
||
class _GuidePopupState extends State<GuidePopup> { | ||
int highlightIndex = -1; | ||
double hLeft, hTop, hWidth, hHeight, hRadius; | ||
|
||
@override | ||
void initState() { | ||
super.initState(); | ||
Rect rect = _calculateNextGuide(); | ||
hRadius = 10; | ||
hLeft = rect.left; | ||
hTop = rect.top; | ||
hHeight = rect.height; | ||
hWidth = rect.width; | ||
} | ||
|
||
@override | ||
Widget build(BuildContext context) { | ||
return GestureDetector( | ||
behavior: HitTestBehavior.opaque, | ||
onTap: () => _next(), | ||
child: Scaffold( | ||
backgroundColor: Colors.transparent, | ||
body: Container( | ||
padding: EdgeInsets.only( | ||
top: hTop - 55, | ||
left: hLeft + (hWidth - 300) / 2, | ||
), | ||
child: Container( | ||
width: 300, | ||
height: 50, | ||
alignment: Alignment.center, | ||
color: Colors.white, | ||
child: Text('${_getShowText()}')), | ||
), | ||
), | ||
); | ||
} | ||
|
||
String _getShowText() { | ||
switch (highlightIndex) { | ||
case 0: | ||
return 'Click here to show dropdown menu.'; | ||
case 1: | ||
return 'Click here to show guide.'; | ||
} | ||
return ''; | ||
} | ||
|
||
_next() { | ||
Rect rect = _calculateNextGuide(); | ||
if (rect == null) { | ||
return; | ||
} | ||
List<RRect> highlights = [ | ||
RRect.fromRectAndRadius( | ||
rect, | ||
Radius.circular(hRadius), | ||
), | ||
]; | ||
setState(() { | ||
EasyPopup.setHighlights(context, highlights); | ||
hLeft = rect.left; | ||
hTop = rect.top; | ||
hHeight = rect.height; | ||
hWidth = rect.width; | ||
}); | ||
} | ||
|
||
Rect _calculateNextGuide() { | ||
highlightIndex++; | ||
if (highlightIndex >= widget.highlightKeys.length) { | ||
_dismiss(); | ||
return null; | ||
} | ||
RenderBox box = | ||
widget.highlightKeys[highlightIndex].currentContext.findRenderObject(); | ||
Offset offset = box.localToGlobal(Offset.zero); | ||
return Rect.fromLTWH( | ||
offset.dx - 5, | ||
offset.dy - 5, | ||
box.size.width + 10, | ||
box.size.height + 10, | ||
); | ||
} | ||
|
||
_dismiss() { | ||
EasyPopup.pop(context); | ||
} | ||
} |
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,2 +1,2 @@ | ||
export 'src/easy_popup.dart'; | ||
export 'src/popup_child.dart'; | ||
export 'src/easy_popup_child.dart'; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,5 +1,5 @@ | ||
import 'package:flutter/material.dart'; | ||
|
||
mixin PopupChild implements Widget { | ||
mixin EasyPopupChild implements Widget { | ||
dismiss(); | ||
} |
Oops, something went wrong.