Skip to content

Commit

Permalink
Merge pull request #29 from telsacoin/develop
Browse files Browse the repository at this point in the history
add discover module
  • Loading branch information
telsav authored Mar 27, 2022
2 parents ee05ce7 + 4ab8fab commit 8a2d793
Show file tree
Hide file tree
Showing 13 changed files with 556 additions and 70 deletions.
182 changes: 122 additions & 60 deletions lib/Screens/home/home.dart
Original file line number Diff line number Diff line change
Expand Up @@ -41,9 +41,8 @@ class _Home extends State<Home> with SingleTickerProviderStateMixin {
bool isLogin = false;
late VideoPlayerController _controller;
ItemListDto dto = new ItemListDto(0, 20);
//late VideoPlayerController _musicController;
//late AnimationController animationController;
late Future<ItemListVo> videos;
late Future<ItemListVo> foryouVideos;
late Future<ItemListVo> followingVideos;
PageController pageController =
PageController(initialPage: 0, viewportFraction: 0.8);
// ScrollController _scrollController = ScrollController(initialScrollOffset:0);
Expand All @@ -56,8 +55,8 @@ class _Home extends State<Home> with SingleTickerProviderStateMixin {
@override
void initState() {
super.initState();
videos = Api.getRecommendItemList(dto);

foryouVideos = Api.getRecommendItemList(dto);
followingVideos = Api.getFollowingItemList(dto);
_controller = VideoPlayerController.network(
"http://appmedia.qq.com/media/cross/assets/uploadFile/20170523/5923d26dac66b.mp4")
..initialize();
Expand Down Expand Up @@ -153,7 +152,7 @@ class _Home extends State<Home> with SingleTickerProviderStateMixin {
if (foryou) {
_controller.pause();
return FutureBuilder<ItemListVo>(
future: videos,
future: foryouVideos,
builder: (context, snapshot) {
print(snapshot.connectionState);
if (snapshot.connectionState == ConnectionState.waiting) {
Expand Down Expand Up @@ -208,60 +207,123 @@ class _Home extends State<Home> with SingleTickerProviderStateMixin {
});
} else {
_controller.play();
return Container(
width: double.infinity,
height: double.infinity,
color: Colors.black,
child: Column(
mainAxisAlignment: MainAxisAlignment.center,
children: <Widget>[
Row(
mainAxisAlignment: MainAxisAlignment.center,
children: <Widget>[
Container(
padding: EdgeInsets.only(bottom: 14),
child: Text(
'Trendy creators',
style: TextStyle(color: Colors.white, fontSize: 20),
))
],
),
Row(
mainAxisAlignment: MainAxisAlignment.center,
children: <Widget>[
Center(
child: Container(
child: Column(
children: <Widget>[
Center(
child: Text('Follow to an account to discover its',
style: TextStyle(
color: Colors.white.withOpacity(0.8))),
),
Center(
child: Text('Latest videos here.',
style: TextStyle(
color: Colors.white.withOpacity(0.8))),
)
],
),
),
)
],
),
Container(
height: 372,
margin: EdgeInsets.only(top: 25),
child: PageView.builder(
dragStartBehavior: DragStartBehavior.down,
controller: pageController,
itemCount: 5,
itemBuilder: (context, position) {
return videoSlider(position);
}),
)
],
));
return FutureBuilder<ItemListVo>(
future: followingVideos,
builder: (context, snapshot) {
print(snapshot.connectionState);
if (snapshot.connectionState == ConnectionState.waiting) {
return loading;
} else if (snapshot.connectionState == ConnectionState.done) {
if (snapshot.hasError) {
return Column(
crossAxisAlignment: CrossAxisAlignment.center,
mainAxisAlignment: MainAxisAlignment.center,
children: [
Container(
width: MediaQuery.of(context).size.width,
height: MediaQuery.of(context).size.height - 24,
color: Colors.black,
child: Center(
child: Text(
'Error, Please restart your app again.',
style: TextStyle(color: Colors.white),
)),
)
],
);
} else if (snapshot.hasData) {
try {
return PageView.builder(
controller: foryouController,
onPageChanged: (index) {
//when the video is changing, release the previous video instance.
//disposeVideo();
//setState(() {});
},
scrollDirection: Axis.vertical,
itemCount: snapshot.data!.itemList!.length,
itemBuilder: (context, index) {
var item = snapshot.data!.itemList![index];
return Videoplayer(
item: item,
width: MediaQuery.of(context).size.width,
heigth: MediaQuery.of(context).size.height,
);
});
} catch (e) {
return Container(
width: MediaQuery.of(context).size.width,
height: MediaQuery.of(context).size.height,
color: Colors.black,
child: Center(
child: Text(
'Error, Please restart your app again.',
style: TextStyle(color: Colors.white),
)),
);
}
} else {
// empty data
return loading;
}
} else {
return Text('State: ${snapshot.connectionState}');
}
});
// return Container(
// width: double.infinity,
// height: double.infinity,
// color: Colors.black,
// child: Column(
// mainAxisAlignment: MainAxisAlignment.center,
// children: <Widget>[
// Row(
// mainAxisAlignment: MainAxisAlignment.center,
// children: <Widget>[
// Container(
// padding: EdgeInsets.only(bottom: 14),
// child: Text(
// 'Trendy creators',
// style: TextStyle(color: Colors.white, fontSize: 20),
// ))
// ],
// ),
// Row(
// mainAxisAlignment: MainAxisAlignment.center,
// children: <Widget>[
// Center(
// child: Container(
// child: Column(
// children: <Widget>[
// Center(
// child: Text('Follow to an account to discover its',
// style: TextStyle(
// color: Colors.white.withOpacity(0.8))),
// ),
// Center(
// child: Text('Latest videos here.',
// style: TextStyle(
// color: Colors.white.withOpacity(0.8))),
// )
// ],
// ),
// ),
// )
// ],
// ),
// Container(
// height: 372,
// margin: EdgeInsets.only(top: 25),
// child: PageView.builder(
// dragStartBehavior: DragStartBehavior.down,
// controller: pageController,
// itemCount: 5,
// itemBuilder: (context, position) {
// return videoSlider(position);
// }),
// )
// ],
// ));
}
}
// Home Screen Code end
Expand Down
2 changes: 2 additions & 0 deletions lib/Screens/login/login.dart
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@ import 'package:shared_preferences/shared_preferences.dart';
import 'package:telsavideo/api/api.dart';
import 'package:telsavideo/components/api.dart';
import 'package:telsavideo/constants.dart';
import 'package:telsavideo/http/base/base_domain.dart';
import 'package:telsavideo/http/util.dart';
import 'package:telsavideo/models/dto/signin/signin_dto.dart';
import 'package:telsavideo/models/vo/signin/signin_vo.dart';
Expand Down Expand Up @@ -62,6 +63,7 @@ class _LoginState extends State<Login> {
SignInVo result = await Api.postLoginResponse(dto);
print(result);
Util.set('isLogin', true);
Util.set(BaseDomain.xUSERTOKEN, result.accessToken);
Util.set("dtok_accessToken", result.accessToken);
Util.set("dtok_token_expire", result.expiresInDate);
Util.set("dtok_refreshToken", result.refreshToken);
Expand Down
80 changes: 80 additions & 0 deletions lib/Screens/search/challenge_item.dart
Original file line number Diff line number Diff line change
@@ -0,0 +1,80 @@
import 'package:flutter/material.dart';
import 'package:telsavideo/api/api.dart';
import 'package:telsavideo/models/dto/discover/discover_challenge_dto.dart';
import 'package:telsavideo/models/dto/discover/discover_music_dto.dart';
import 'package:telsavideo/models/vo/discover/discover_challenage_vo.dart';
import 'package:telsavideo/screens/loading/loading.dart';

class ChallengeItem extends StatefulWidget {
@override
State<StatefulWidget> createState() {
// TODO: implement createState
throw UnimplementedError();
}
}

class _ChallengeItemState extends State<ChallengeItem> {
DiscoverChallengeDto dto = new DiscoverChallengeDto(0, 20);

late Future<DiscoverChallengeVo> getDiscoverChallenges;
@override
void initState() {
// TODO: implement initState
super.initState();
getDiscoverChallenges = Api.getDiscoverChanllenge(dto);
}

@override
Widget build(BuildContext context) {
// TODO: implement build
double width = MediaQuery.of(context).size.width;
return FutureBuilder<DiscoverChallengeVo>(
future: getDiscoverChallenges,
builder: (context, snapshot) {
print(snapshot.connectionState);
if (snapshot.connectionState == ConnectionState.waiting) {
return loading;
} else if (snapshot.connectionState == ConnectionState.done) {
if (snapshot.hasError) {
return Column(
crossAxisAlignment: CrossAxisAlignment.center,
mainAxisAlignment: MainAxisAlignment.center,
children: [
Container(
width: MediaQuery.of(context).size.width,
height: MediaQuery.of(context).size.height - 24,
color: Colors.black,
child: Center(
child: Text(
'Error, Please restart your app again.',
style: TextStyle(color: Colors.white),
)),
)
],
);
} else if (snapshot.hasData) {
try {
return Container();
} catch (e) {
return Container(
width: MediaQuery.of(context).size.width,
height: MediaQuery.of(context).size.height,
color: Colors.black,
child: Center(
child: Text(
'Error, Please restart your app again.',
style: TextStyle(color: Colors.white),
)),
);
}
} else {
// empty data
return loading;
}
} else {
return Text('State: ${snapshot.connectionState}');
}
},
);
}
}
Loading

0 comments on commit 8a2d793

Please sign in to comment.