Skip to content

Commit ba72870

Browse files
增加 lottie 动画
1 parent af651c3 commit ba72870

File tree

4 files changed

+44
-6
lines changed

4 files changed

+44
-6
lines changed

lib/page/home/home_page.dart

Lines changed: 26 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@ import 'package:gsy_github_app_flutter/page/trend/trend_page.dart';
1111
import 'package:gsy_github_app_flutter/widget/gsy_tabbar_widget.dart';
1212
import 'package:gsy_github_app_flutter/widget/gsy_title_bar.dart';
1313
import 'package:gsy_github_app_flutter/page/home/widget/home_drawer.dart';
14+
import 'package:lottie/lottie.dart';
1415

1516
/// 主页
1617
/// Created by guoshuyu
@@ -28,6 +29,7 @@ class _HomePageState extends State<HomePage> {
2829
final GlobalKey<DynamicPageState> dynamicKey = GlobalKey();
2930
final GlobalKey<TrendPageState> trendKey = GlobalKey();
3031
final GlobalKey<MyPageState> myKey = GlobalKey();
32+
final GlobalKey rightKey = GlobalKey();
3133

3234
/// 不退出
3335
_dialogExitApp(BuildContext context) async {
@@ -54,7 +56,8 @@ class _HomePageState extends State<HomePage> {
5456
@override
5557
Widget build(BuildContext context) {
5658
List<Widget> tabs = [
57-
_renderTab(GSYICons.MAIN_DT, GSYLocalizations.i18n(context)!.home_dynamic),
59+
_renderTab(
60+
GSYICons.MAIN_DT, GSYLocalizations.i18n(context)!.home_dynamic),
5861
_renderTab(GSYICons.MAIN_QS, GSYLocalizations.i18n(context)!.home_trend),
5962
_renderTab(GSYICons.MAIN_MY, GSYLocalizations.i18n(context)!.home_my),
6063
];
@@ -91,11 +94,28 @@ class _HomePageState extends State<HomePage> {
9194
indicatorColor: GSYColors.white,
9295
title: GSYTitleBar(
9396
GSYLocalizations.of(context)!.currentLocalized!.app_name,
94-
iconData: GSYICons.MAIN_SEARCH,
95-
needRightLocalIcon: true,
96-
onRightIconPressed: (centerPosition) {
97-
NavigatorUtils.goSearchPage(context, centerPosition);
98-
},
97+
rightWidget: InkWell(
98+
onTap: () {
99+
RenderBox renderBox2 =
100+
rightKey.currentContext?.findRenderObject() as RenderBox;
101+
var position = renderBox2.localToGlobal(Offset.zero);
102+
var size = renderBox2.size;
103+
var centerPosition = Offset(
104+
position.dx + size.width / 2,
105+
position.dy + size.height / 2,
106+
);
107+
NavigatorUtils.goSearchPage(context, centerPosition);
108+
},
109+
child: Container(
110+
key: rightKey,
111+
alignment: Alignment.centerRight,
112+
child: Lottie.asset('static/file/search.json',
113+
width: 70,
114+
height: 80,
115+
fit: BoxFit.cover,
116+
alignment: Alignment.centerRight),
117+
),
118+
),
99119
),
100120
),
101121
);

pubspec.lock

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -46,6 +46,14 @@ packages:
4646
url: "https://pub.flutter-io.cn"
4747
source: hosted
4848
version: "2.0.11"
49+
archive:
50+
dependency: transitive
51+
description:
52+
name: archive
53+
sha256: cb6a278ef2dbb298455e1a713bda08524a175630ec643a242c399c932a0a1f7d
54+
url: "https://pub.flutter-io.cn"
55+
source: hosted
56+
version: "3.6.1"
4957
args:
5058
dependency: transitive
5159
description:
@@ -670,6 +678,14 @@ packages:
670678
url: "https://pub.flutter-io.cn"
671679
source: hosted
672680
version: "1.2.0"
681+
lottie:
682+
dependency: "direct main"
683+
description:
684+
name: lottie
685+
sha256: "1f0ce68112072d66ea271a9841994fa8d16442e23d8cf8996c9fa74174e58b4e"
686+
url: "https://pub.flutter-io.cn"
687+
source: hosted
688+
version: "3.0.0"
673689
macros:
674690
dependency: transitive
675691
description:

pubspec.yaml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -76,6 +76,7 @@ dependencies:
7676
simple_animations: 5.0.2
7777
supercharged: 2.1.1
7878
animations: 2.0.11
79+
lottie: 3.0.0
7980
auto_size_text: 3.0.0
8081
flutter_localizations:
8182
sdk: flutter

static/file/search.json

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
{"v":"5.5.8","fr":24,"ip":0,"op":35,"w":480,"h":480,"nm":"Comp 1","ddd":0,"assets":[],"layers":[{"ddd":0,"ind":2,"ty":4,"nm":"Shape Layer 2","sr":1,"ks":{"o":{"a":0,"k":100,"ix":11},"r":{"a":0,"k":-45,"ix":10},"p":{"a":0,"k":[265,260,0],"ix":2},"a":{"a":0,"k":[0,19.75,0],"ix":1},"s":{"a":0,"k":[100,100,100],"ix":6}},"ao":0,"shapes":[{"ty":"gr","it":[{"ind":0,"ty":"sh","ix":1,"ks":{"a":0,"k":{"i":[[0,0],[0,0]],"o":[[0,0],[0,0]],"v":[[0,19.75],[0,66.19]],"c":false},"ix":2},"nm":"Path 1","mn":"ADBE Vector Shape - Group","hd":false},{"ty":"tm","s":{"a":1,"k":[{"i":{"x":[0.667],"y":[1]},"o":{"x":[0.333],"y":[0]},"t":2,"s":[0]},{"i":{"x":[0.667],"y":[1]},"o":{"x":[0.333],"y":[0]},"t":7,"s":[25]},{"i":{"x":[0.667],"y":[1]},"o":{"x":[0.333],"y":[0]},"t":12,"s":[0]},{"i":{"x":[0.667],"y":[1]},"o":{"x":[0.333],"y":[0]},"t":22,"s":[0]},{"i":{"x":[0.667],"y":[1]},"o":{"x":[0.333],"y":[0]},"t":27,"s":[25]},{"t":32,"s":[0]}],"ix":1},"e":{"a":0,"k":100,"ix":2},"o":{"a":0,"k":0,"ix":3},"m":1,"ix":2,"nm":"Trim Paths 1","mn":"ADBE Vector Filter - Trim","hd":false},{"ty":"st","c":{"a":0,"k":[1,1,1,1],"ix":3},"o":{"a":0,"k":100,"ix":4},"w":{"a":1,"k":[{"i":{"x":[0.667],"y":[1]},"o":{"x":[0.333],"y":[0]},"t":2,"s":[18]},{"i":{"x":[0.667],"y":[1]},"o":{"x":[0.333],"y":[0]},"t":12,"s":[9]},{"i":{"x":[0.833],"y":[1]},"o":{"x":[0.333],"y":[0]},"t":22,"s":[9]},{"t":32,"s":[18]}],"ix":5},"lc":2,"lj":1,"ml":4,"bm":0,"nm":"Stroke 1","mn":"ADBE Vector Graphic - Stroke","hd":false},{"ty":"tr","p":{"a":0,"k":[0,0],"ix":2},"a":{"a":0,"k":[0,0],"ix":1},"s":{"a":0,"k":[100,100],"ix":3},"r":{"a":0,"k":0,"ix":6},"o":{"a":0,"k":100,"ix":7},"sk":{"a":0,"k":0,"ix":4},"sa":{"a":0,"k":0,"ix":5},"nm":"Transform"}],"nm":"Shape 1","np":4,"cix":2,"bm":0,"ix":1,"mn":"ADBE Vector Group","hd":false}],"ip":0,"op":240,"st":0,"bm":0},{"ddd":0,"ind":3,"ty":4,"nm":"Shape Layer 1","sr":1,"ks":{"o":{"a":0,"k":100,"ix":11},"r":{"a":0,"k":-45,"ix":10},"p":{"a":1,"k":[{"i":{"x":0.667,"y":1},"o":{"x":0.333,"y":0},"t":2,"s":[229.645,224.645,0],"to":[-2.542,-2.458,0],"ti":[0,0,0]},{"i":{"x":0.667,"y":1},"o":{"x":0.333,"y":0},"t":7,"s":[214.395,209.895,0],"to":[0,0,0],"ti":[-2.542,-2.458,0]},{"i":{"x":0.667,"y":0.667},"o":{"x":0.333,"y":0.333},"t":12,"s":[229.645,224.645,0],"to":[0,0,0],"ti":[0,0,0]},{"i":{"x":0.667,"y":1},"o":{"x":0.333,"y":0},"t":22,"s":[229.645,224.645,0],"to":[-2.542,-2.458,0],"ti":[0,0,0]},{"i":{"x":0.667,"y":1},"o":{"x":0.333,"y":0},"t":27,"s":[214.395,209.895,0],"to":[0,0,0],"ti":[-2.542,-2.458,0]},{"t":32,"s":[229.645,224.645,0]}],"ix":2},"a":{"a":0,"k":[-24.742,-25.176,0],"ix":1},"s":{"a":0,"k":[100,100,100],"ix":6}},"ao":0,"shapes":[{"ty":"gr","it":[{"ind":0,"ty":"sh","ix":1,"ks":{"a":1,"k":[{"i":{"x":0.667,"y":1},"o":{"x":0.333,"y":0},"t":2,"s":[{"i":[[-27.614,0],[0,-27.614],[27.614,0],[0,27.614]],"o":[[27.614,0],[0,27.614],[-27.614,0],[0,-27.614]],"v":[[0,-50],[50,0],[0,50],[-50,0]],"c":true}]},{"i":{"x":0.667,"y":1},"o":{"x":0.333,"y":0},"t":12,"s":[{"i":[[27.69,0],[0,-27.614],[-27.69,0],[0,27.614]],"o":[[-27.69,0],[0,27.614],[27.69,0],[0,-27.614]],"v":[[0.265,-50],[-49.872,0],[0.265,50],[50.402,0]],"c":true}]},{"i":{"x":0.667,"y":1},"o":{"x":0.333,"y":0},"t":22,"s":[{"i":[[27.69,0],[0,-27.614],[-27.69,0],[0,27.614]],"o":[[-27.69,0],[0,27.614],[27.69,0],[0,-27.614]],"v":[[0.265,-50],[-49.872,0],[0.265,50],[50.402,0]],"c":true}]},{"t":32,"s":[{"i":[[-27.614,0],[0,-27.614],[27.614,0],[0,27.614]],"o":[[27.614,0],[0,27.614],[-27.614,0],[0,-27.614]],"v":[[0,-50],[50,0],[0,50],[-50,0]],"c":true}]}],"ix":2},"nm":"Path 1","mn":"ADBE Vector Shape - Group","hd":false},{"ty":"st","c":{"a":0,"k":[1,1,1,1],"ix":3},"o":{"a":0,"k":100,"ix":4},"w":{"a":1,"k":[{"i":{"x":[0.667],"y":[1]},"o":{"x":[0.333],"y":[0]},"t":2,"s":[18]},{"i":{"x":[0.667],"y":[1]},"o":{"x":[0.333],"y":[0]},"t":12,"s":[9]},{"i":{"x":[0.833],"y":[1]},"o":{"x":[0.333],"y":[0]},"t":22,"s":[9]},{"t":32,"s":[18]}],"ix":5},"lc":1,"lj":1,"ml":4,"bm":0,"nm":"Stroke 1","mn":"ADBE Vector Graphic - Stroke","hd":false},{"ty":"tr","p":{"a":0,"k":[-24.742,-25.176],"ix":2},"a":{"a":0,"k":[0,0],"ix":1},"s":{"a":0,"k":[99.958,100],"ix":3},"r":{"a":0,"k":0,"ix":6},"o":{"a":0,"k":100,"ix":7},"sk":{"a":0,"k":0,"ix":4},"sa":{"a":0,"k":0,"ix":5},"nm":"Transform"}],"nm":"Ellipse 1","np":3,"cix":2,"bm":0,"ix":1,"mn":"ADBE Vector Group","hd":false}],"ip":0,"op":240,"st":0,"bm":0}],"markers":[]}

0 commit comments

Comments
 (0)