my_page.dart 14 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414
  1. import 'dart:async';
  2. import 'package:flutter/material.dart';
  3. import 'package:flutter_svg/svg.dart';
  4. import 'package:link/view/component/button.dart';
  5. import 'package:link/view/component/link_btn.dart';
  6. import 'package:link/view/component/menu.dart';
  7. import 'package:link/view/guide.dart';
  8. import '../constants.dart';
  9. import '../utils/size_fit.dart';
  10. import 'component/top_container.dart';
  11. class MyIndex extends StatefulWidget {
  12. const MyIndex({Key? key}) : super(key: key);
  13. @override
  14. State<MyIndex> createState() => _MyIndexState();
  15. }
  16. class _MyIndexState extends State<MyIndex> {
  17. GlobalKey addLinkkey = GlobalKey();
  18. GlobalKey itemkey = GlobalKey();
  19. bool showGuide = false;
  20. Offset itemOffset = const Offset(0, 0);
  21. Offset guideOffset = const Offset(0, 0);
  22. int guideStep = 1;
  23. @override
  24. void initState() {
  25. // TODO: implement initState
  26. super.initState();
  27. Timer(const Duration(seconds: 2), () {
  28. // getSize();
  29. });
  30. }
  31. getSize() {
  32. RenderBox widget2 =
  33. addLinkkey.currentContext!.findRenderObject() as RenderBox;
  34. RenderBox widget = itemkey.currentContext!.findRenderObject() as RenderBox;
  35. var offset = widget.localToGlobal(Offset.zero);
  36. setState(() {
  37. showGuide = true;
  38. itemOffset = offset;
  39. guideOffset = widget2.localToGlobal(Offset.zero);
  40. });
  41. }
  42. Widget guideItem() {
  43. String title = '开始探索 2/4';
  44. if (guideStep==2){
  45. title = '开始探索 3/4';
  46. }
  47. else if (guideStep==3){
  48. title = '开始探索 4/4';
  49. }
  50. else if (guideStep==4){
  51. title = '完成';
  52. }
  53. if (showGuide) {
  54. return Container(
  55. color: const Color(0xBF000000),
  56. child: Column(
  57. children: [
  58. Container(
  59. height: guideStep==1?itemOffset.dy:guideOffset.dy,
  60. alignment: Alignment.bottomCenter,
  61. child: Column(
  62. children: [
  63. Expanded(child: Container()),
  64. GuideTip(
  65. content: '这是我刚添加的第1个链接,点击跳转查看;如需调整,仍可继续编辑',
  66. direction: 2,
  67. width: 316.px),
  68. SvgPicture.asset(
  69. 'assets/icons/arrow_corner.svg',
  70. width: 28.px,
  71. height: 14.px,
  72. color: const Color(0xFF0000FF),
  73. )
  74. ],
  75. ),
  76. ),
  77. Container(
  78. width: 295.px,
  79. height: 52.px,
  80. padding: EdgeInsets.only(left: 16.px, right: 16.px),
  81. decoration: BoxDecoration(
  82. color: kThemeColor,
  83. border:
  84. Border.all(color: const Color(0xFF131314), width: 4.px),
  85. borderRadius: BorderRadius.circular(26.px)),
  86. child: Row(
  87. children: [
  88. SvgPicture.asset('assets/icons/link.svg'),
  89. SizedBox(
  90. width: 10.px,
  91. ),
  92. Expanded(
  93. child: Text(
  94. '添加链接',
  95. style: TextStyle(
  96. color: const Color(0xFF131314), fontSize: 14.px),
  97. )),
  98. SvgPicture.asset('assets/icons/arrow_right.svg')
  99. ],
  100. ),
  101. ),
  102. Expanded(child: Container()),
  103. LinkButton(
  104. title: title,
  105. btnWidth: 172.px,
  106. disable: false,
  107. isBlack: false,
  108. callback: () {
  109. setState(() {
  110. guideStep = guideStep+1;
  111. // showGuide = false;
  112. });
  113. }),
  114. SizedBox(
  115. height: 64.px,
  116. )
  117. ],
  118. ),
  119. );
  120. }
  121. return Container();
  122. }
  123. Widget guideAddLink() {
  124. if (showGuide) {
  125. return Container(
  126. color: const Color(0xBF000000),
  127. child: Column(
  128. children: [
  129. Container(
  130. height: guideOffset.dy,
  131. alignment: Alignment.bottomCenter,
  132. child: Column(
  133. children: [
  134. Expanded(child: Container()),
  135. GuideTip(
  136. content: '这是我刚添加的第1个链接,点击跳转查看;如需调整,仍可继续编辑',
  137. direction: 2,
  138. width: 316.px),
  139. SvgPicture.asset(
  140. 'assets/icons/arrow_corner.svg',
  141. width: 28.px,
  142. height: 14.px,
  143. color: const Color(0xFF0000FF),
  144. )
  145. ],
  146. ),
  147. ),
  148. Container(
  149. width: 295.px,
  150. height: 52.px,
  151. padding: EdgeInsets.only(left: 16.px, right: 16.px),
  152. decoration: BoxDecoration(
  153. color: kThemeColor,
  154. border:
  155. Border.all(color: const Color(0xFF131314), width: 4.px),
  156. borderRadius: BorderRadius.circular(26.px)),
  157. child: Row(
  158. children: [
  159. SvgPicture.asset('assets/icons/link.svg'),
  160. SizedBox(
  161. width: 10.px,
  162. ),
  163. Expanded(
  164. child: Text(
  165. '添加链接',
  166. style: TextStyle(
  167. color: const Color(0xFF131314), fontSize: 14.px),
  168. )),
  169. SvgPicture.asset('assets/icons/arrow_right.svg')
  170. ],
  171. ),
  172. ),
  173. Expanded(child: Container()),
  174. LinkButton(
  175. title: '完成',
  176. btnWidth: 172.px,
  177. disable: false,
  178. isBlack: false,
  179. callback: () {
  180. setState(() {
  181. showGuide = false;
  182. });
  183. }),
  184. SizedBox(
  185. height: 64.px,
  186. )
  187. ],
  188. ),
  189. );
  190. }
  191. return Container();
  192. }
  193. Widget userCenter() {
  194. return Stack(
  195. children: [
  196. Column(
  197. children: [
  198. SizedBox(
  199. height: 92.px,
  200. ),
  201. Container(
  202. width: 120.px,
  203. height: 120.px,
  204. decoration: BoxDecoration(
  205. image: const DecorationImage(
  206. image: AssetImage('assets/images/6.png'),
  207. ),
  208. border: Border.all(color: Colors.black, width: 4.px),
  209. borderRadius: BorderRadius.circular(60.px)),
  210. ),
  211. SizedBox(
  212. height: 10.px,
  213. ),
  214. Text(
  215. 'Leon 123',
  216. style: TextStyle(
  217. color: Colors.black,
  218. fontSize: 32.px,
  219. fontWeight: FontWeight.bold),
  220. ),
  221. Container(
  222. margin: EdgeInsets.only(left: 62.px, right: 62.px, bottom: 24.px),
  223. child: Text(
  224. '时尚感的营造和女性的年龄、身材并没有直接的关联,而是与她们对时尚的理解、态度息而是与她们对时尚的理解、而是',
  225. style:
  226. TextStyle(color: const Color(0x99131314), fontSize: 13.px),
  227. ),
  228. ),
  229. Button(
  230. key: itemkey,
  231. child: Container(
  232. width: 295.px,
  233. height: 52.px,
  234. padding: EdgeInsets.only(left: 16.px, right: 16.px),
  235. decoration: BoxDecoration(
  236. border: Border.all(
  237. color: const Color(0xFF131314), width: 4.px),
  238. borderRadius: BorderRadius.circular(26.px)),
  239. child: Row(
  240. mainAxisAlignment: MainAxisAlignment.center,
  241. crossAxisAlignment: CrossAxisAlignment.center,
  242. children: [
  243. SvgPicture.asset('assets/icons/link.svg'),
  244. SizedBox(
  245. width: 10.px,
  246. ),
  247. Expanded(
  248. child: Column(
  249. mainAxisAlignment: MainAxisAlignment.start,
  250. crossAxisAlignment: CrossAxisAlignment.start,
  251. children: [
  252. Text(
  253. 'Leon',
  254. style: TextStyle(
  255. color: const Color(0xFF131314),
  256. fontSize: 14.px),
  257. ),
  258. Text(
  259. '描述文字描述文字描述文字描述文字...',
  260. style: TextStyle(
  261. color: const Color(0x99131314),
  262. fontSize: 10.px),
  263. )
  264. ],
  265. )),
  266. SvgPicture.asset('assets/icons/arrow_right.svg')
  267. ],
  268. )),
  269. callback: () {}),
  270. SizedBox(
  271. height: 20.px,
  272. ),
  273. Button(
  274. key: addLinkkey,
  275. child: Container(
  276. width: 295.px,
  277. height: 52.px,
  278. padding: EdgeInsets.only(left: 16.px, right: 16.px),
  279. decoration: BoxDecoration(
  280. border: Border.all(
  281. color: const Color(0xFF131314), width: 4.px),
  282. borderRadius: BorderRadius.circular(26.px)),
  283. child: Row(
  284. children: [
  285. SvgPicture.asset('assets/icons/link.svg'),
  286. SizedBox(
  287. width: 10.px,
  288. ),
  289. Expanded(
  290. child: Text(
  291. '添加链接',
  292. style: TextStyle(
  293. color: const Color(0xFF131314), fontSize: 14.px),
  294. )),
  295. SvgPicture.asset('assets/icons/arrow_right.svg')
  296. ],
  297. ),
  298. ),
  299. callback: () {}),
  300. ],
  301. ),
  302. // Positioned(left: 0, right: 0, bottom: 0, top: 0, child: guideItem()),
  303. // Positioned(left: 0, right: 0, bottom: 0, top: 0, child: guideAddLink()),
  304. ],
  305. );
  306. }
  307. @override
  308. Widget build(BuildContext context) {
  309. SizeFit.initialize(context);
  310. return Material(
  311. color: kThemeColor,
  312. child: TopContainer(child: //userCenter()
  313. Stack(children: [
  314. Positioned(
  315. left: 0,
  316. right: 0,
  317. top: 0,
  318. bottom: 0,
  319. child: Container(
  320. color: const Color(0xBF000000),
  321. child: Stack(
  322. children: [
  323. Container(
  324. width: 375.px,
  325. height: 72.px,
  326. decoration: const BoxDecoration(
  327. gradient: LinearGradient(
  328. begin: Alignment.centerLeft,
  329. end: Alignment.centerRight,
  330. colors: [
  331. Color(0x00FFF700),
  332. Color(0x00FFF700),
  333. Color(0xFFFFF700),
  334. ],
  335. stops: [0,0.25,1]
  336. ),
  337. ),
  338. ),
  339. ],
  340. ),
  341. )),
  342. Positioned(left: 0,
  343. width: 120.px,
  344. top: 0,
  345. bottom: 0,child: Menu())
  346. ])
  347. // Positioned(
  348. // left: 0,
  349. // top: 0,
  350. // right: 0,
  351. // bottom: 0,
  352. // child: Container(
  353. // color: kThemeColor,
  354. // alignment: Alignment.center,
  355. // child: Column(children: [
  356. // SizedBox(
  357. // height: 100.px,
  358. // ),
  359. // GuideTip(
  360. // content: '这是我刚添加的第1个链接,点击跳转查看;如需调整,仍可继续编辑',
  361. // direction: 2,
  362. // width: 316.px),
  363. // SvgPicture.asset('assets/icons/arrow_corner.svg',width: 28.px,height: 14.px,color: const Color(0xFF0000FF),)
  364. // ]),
  365. // )),
  366. // Positioned(
  367. // left: 0,
  368. // top: 0,
  369. // right: 0,
  370. // bottom: 0,
  371. // child: Container(
  372. // color: kThemeColor,
  373. // alignment: Alignment.center,
  374. // child: Column(children: [
  375. // const IndexWelcome(),
  376. // ]),
  377. // )),
  378. // Container(
  379. // width: 375.px,
  380. // height: 72.px,
  381. // decoration:const BoxDecoration(
  382. // gradient: LinearGradient(
  383. // begin: Alignment.centerLeft,
  384. // end: Alignment.centerRight,
  385. // colors: [
  386. // Color(0x00FFF700),
  387. // Color(0x00FFF700),
  388. // kThemeColor
  389. // ]),
  390. // ),
  391. // ),
  392. // const IndexWelcome(),
  393. // ]
  394. // )
  395. ));
  396. }
  397. }