Skip to content

Commit

Permalink
校准了首页右侧搜索打开动画
Browse files Browse the repository at this point in the history
  • Loading branch information
CarGuo committed Mar 24, 2020
1 parent 008ea5b commit 7193687
Show file tree
Hide file tree
Showing 7 changed files with 28 additions and 12 deletions.
4 changes: 2 additions & 2 deletions lib/common/utils/navigator_utils.dart
Original file line number Diff line number Diff line change
Expand Up @@ -155,13 +155,13 @@ class NavigatorUtils {
}

///搜索
static Future goSearchPage(BuildContext context) {
static Future goSearchPage(BuildContext context, Offset centerPosition) {
return showGeneralDialog(
context: context,
pageBuilder: (BuildContext buildContext, Animation<double> animation,
Animation<double> secondaryAnimation) {
return Builder(builder: (BuildContext context) {
return pageContainer(SearchPage());
return pageContainer(SearchPage(centerPosition));
});
},
barrierDismissible: false,
Expand Down
4 changes: 2 additions & 2 deletions lib/page/home/home_page.dart
Original file line number Diff line number Diff line change
Expand Up @@ -95,8 +95,8 @@ class _HomePageState extends State<HomePage> {
GSYLocalizations.of(context).currentLocalized.app_name,
iconData: GSYICons.MAIN_SEARCH,
needRightLocalIcon: true,
onPressed: () {
NavigatorUtils.goSearchPage(context);
onRightIconPressed: (centerPosition) {
NavigatorUtils.goSearchPage(context, centerPosition);
},
),
),
Expand Down
2 changes: 1 addition & 1 deletion lib/page/issue/issue_detail_page.dart
Original file line number Diff line number Diff line change
Expand Up @@ -376,7 +376,7 @@ class _IssueDetailPageState extends State<IssueDetailPage>
rightWidget: widgetContent,
needRightLocalIcon: widget.needHomeIcon,
iconData: GSYICons.HOME,
onPressed: () {
onRightIconPressed: (_) {
NavigatorUtils.goReposDetail(
context, widget.userName, widget.reposName);
},
Expand Down
2 changes: 1 addition & 1 deletion lib/page/notify_page.dart
Original file line number Diff line number Diff line change
Expand Up @@ -127,7 +127,7 @@ class _NotifyPageState extends State<NotifyPage>
GSYLocalizations.i18n(context).notify_title,
iconData: GSYICons.NOTIFY_ALL_READ,
needRightLocalIcon: true,
onPressed: () {
onRightIconPressed: (_) {
CommonUtils.showLoadingDialog(context);
UserDao.setAllNotificationAsReadDao().then((res) {
Navigator.pop(context);
Expand Down
2 changes: 1 addition & 1 deletion lib/page/push/push_detail_page.dart
Original file line number Diff line number Diff line change
Expand Up @@ -132,7 +132,7 @@ class _PushDetailPageState extends State<PushDetailPage>
rightWidget: widgetContent,
needRightLocalIcon: widget.needHomeIcon,
iconData: GSYICons.HOME,
onPressed: () {
onRightIconPressed: (_) {
NavigatorUtils.goReposDetail(
context, widget.userName, widget.reposName);
},
Expand Down
7 changes: 5 additions & 2 deletions lib/page/search/search_page.dart
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,10 @@ import 'package:gsy_github_app_flutter/page/user/widget/user_item.dart';
* on 2018/7/24.
*/
class SearchPage extends StatefulWidget {
final Offset centerPosition;

SearchPage(this.centerPosition);

@override
_SearchPageState createState() => _SearchPageState();
}
Expand Down Expand Up @@ -145,8 +149,7 @@ class _SearchPageState extends State<SearchPage>
child: CRAnimation(
minR: MediaQuery.of(context).size.height - 8,
maxR: 0,
offset: Offset(MediaQuery.of(context).size.width - 50,
MediaQuery.of(context).padding.top - 10),
offset: widget.centerPosition,
animation: animation,
child: new Scaffold(
resizeToAvoidBottomPadding: false,
Expand Down
19 changes: 16 additions & 3 deletions lib/widget/gsy_title_bar.dart
Original file line number Diff line number Diff line change
Expand Up @@ -10,15 +10,17 @@ class GSYTitleBar extends StatelessWidget {

final IconData iconData;

final VoidCallback onPressed;
final ValueChanged onRightIconPressed;

final bool needRightLocalIcon;

final Widget rightWidget;

final GlobalKey rightKey = GlobalKey();

GSYTitleBar(this.title,
{this.iconData,
this.onPressed,
this.onRightIconPressed,
this.needRightLocalIcon = false,
this.rightWidget});

Expand All @@ -30,9 +32,20 @@ class GSYTitleBar extends StatelessWidget {
? new IconButton(
icon: new Icon(
iconData,
key: rightKey,
size: 19.0,
),
onPressed: onPressed)
onPressed: () {
RenderBox renderBox2 =
rightKey.currentContext?.findRenderObject();
var position = renderBox2.localToGlobal(Offset.zero);
var size = renderBox2.size;
var centerPosition = Offset(
position.dx + size.width / 2,
position.dy + size.height / 2,
);
onRightIconPressed?.call(centerPosition);
})
: new Container();
}
return Container(
Expand Down

0 comments on commit 7193687

Please sign in to comment.