123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179 |
- import 'package:flutter/material.dart';
- class RecommendProvider extends State<StatefulWidget>
- with ChangeNotifier, TickerProviderStateMixin {
- bool ifShowBottom = true;
- double screenHeight = 1.0;
- List<MainInfo> infos = <MainInfo>[];
- List<MainInfo> followed = <MainInfo>[];
- late TabController controller;
- late MainInfo mainInfo;
- late Reply reply;
- RecommendProvider() {
- controller = TabController(vsync: this, length: 2);
- mainInfo = MainInfo(
- avatarUrl:
- "https://pic2.zhimg.com/v2-a88cd7618933272ca681f86398e6240d_xll.jpg",
- content:
- "奥斯卡答复哈士大夫哈师大发输电和健康阿萨德鸿福路口氨基酸的鸿福路口啊,奥斯卡答复哈士大夫哈师大发输电和健康阿萨德鸿福路口氨基酸的鸿福路口啊",
- favCount: 109,
- replyCount: 212,
- shareCount: 317,
- userName: "马有发",
- videoPath: "assets/images/pingguo.jpeg",
- desc: "马友发做的一个有意思的模拟抖音的小App,用的Flutter哦~",
- ifFaved: false);
- reply = Reply(
- ifFaved: true,
- afterReplies: <Reply>[],
- replyContent: "真可爱,真好看,真厉害~真可爱,真好看,真厉害~",
- replyMakerAvatar:
- "https://pic2.zhimg.com/v2-a88cd7618933272ca681f86398e6240d_xll.jpg",
- replyMakerName: "ABC",
- whenReplied: "3小时前");
- infos.add(MainInfo(
- avatarUrl:
- "https://pic2.zhimg.com/v2-a88cd7618933272ca681f86398e6240d_xll.jpg",
- content: "弗兰克斯代理费绿色出行女郎自行车卡水电费卡;双列的会计法第十六届法律深刻江东父老;看氨基酸的;联发科",
- favCount: 219,
- replyCount: 329,
- shareCount: 1222,
- userName: "范德彪",
- videoPath: "assets/images/sky.jpg",
- desc: "这个天空的图有点好看",
- ifFaved: true));
- infos.add(MainInfo(
- avatarUrl:
- "https://pic2.zhimg.com/v2-a88cd7618933272ca681f86398e6240d_xll.jpg",
- content: "弗兰克斯代理费绿色出行女郎自行车卡水电费卡;双列的会计法第十六届法律深刻江东父老;看氨基酸的;联发科",
- favCount: 119,
- replyCount: 189,
- shareCount: 262,
- userName: "马大帅",
- videoPath: "assets/images/temple.jpg",
- desc: "我喜欢拜佛",
- ifFaved: true));
- infos.add(MainInfo(
- avatarUrl:
- "https://pic2.zhimg.com/v2-a88cd7618933272ca681f86398e6240d_xll.jpg",
- content: "弗兰克斯代理费绿色出行女郎自行车卡水电费卡;双列的会计法第十六届法律深刻江东父老;看氨基酸的;联发科",
- favCount: 98,
- replyCount: 222,
- shareCount: 1983,
- userName: "ABC",
- videoPath: "assets/images/woman.jpg",
- desc: "黑色女人有黑色的美",
- ifFaved: true));
- followed.add(MainInfo(
- avatarUrl:
- "https://pic2.zhimg.com/v2-a88cd7618933272ca681f86398e6240d_xll.jpg",
- content: "弗兰克斯代理费绿色出行女郎自行车卡水电费卡;双列的会计法第十六届法律深刻江东父老;看氨基酸的;联发科",
- favCount: 219,
- replyCount: 329,
- shareCount: 1222,
- userName: "范德彪",
- videoPath: "assets/images/whitehouse.jpg",
- desc: "这个天空的图有点好看",
- ifFaved: true));
- followed.add(MainInfo(
- avatarUrl:
- "https://pic2.zhimg.com/v2-a88cd7618933272ca681f86398e6240d_xll.jpg",
- content: "弗兰克斯代理费绿色出行女郎自行车卡水电费卡;双列的会计法第十六届法律深刻江东父老;看氨基酸的;联发科",
- favCount: 119,
- replyCount: 189,
- shareCount: 262,
- userName: "马大帅",
- videoPath: "assets/images/waterdrop.jpg",
- desc: "我喜欢拜佛",
- ifFaved: true));
- followed.add(MainInfo(
- avatarUrl:
- "https://pic2.zhimg.com/v2-a88cd7618933272ca681f86398e6240d_xll.jpg",
- content: "弗兰克斯代理费绿色出行女郎自行车卡水电费卡;双列的会计法第十六届法律深刻江东父老;看氨基酸的;联发科",
- favCount: 98,
- replyCount: 222,
- shareCount: 1983,
- userName: "ABC",
- videoPath: "assets/images/woman2.jpg",
- desc: "黑色女人有黑色的美",
- ifFaved: true));
- }
- setScreenHeight(height) {
- screenHeight = height;
- notifyListeners();
- }
- setTabController(ctrl) {
- controller = ctrl;
- // notifyListeners();
- }
- hideBottomBar() {
- ifShowBottom = false;
- notifyListeners();
- }
- tapFav() {
- mainInfo.ifFaved = !mainInfo.ifFaved;
- if (mainInfo.ifFaved) {
- mainInfo.favCount += 1;
- } else {
- mainInfo.favCount -= 1;
- }
- notifyListeners();
- }
- @override
- Widget build(BuildContext context) {
- return Container();
- }
- }
- class MainInfo {
- String avatarUrl;
- String userName;
- String content;
- int favCount;
- int replyCount;
- int shareCount;
- String videoPath;
- String desc;
- bool ifFaved;
- MainInfo(
- {required this.avatarUrl,
- required this.content,
- required this.favCount,
- required this.replyCount,
- required this.shareCount,
- required this.userName,
- required this.videoPath,
- required this.desc,
- required this.ifFaved});
- }
- class Reply {
- String replyMakerName;
- String replyMakerAvatar;
- String replyContent;
- String whenReplied;
- bool ifFaved;
- List<Reply> afterReplies;
- Reply(
- {required this.ifFaved,
- required this.afterReplies,
- required this.replyContent,
- required this.replyMakerAvatar,
- required this.replyMakerName,
- required this.whenReplied});
- }
|