-
Notifications
You must be signed in to change notification settings - Fork 63
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #29 from telsacoin/develop
add discover module
- Loading branch information
Showing
13 changed files
with
556 additions
and
70 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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}'); | ||
} | ||
}, | ||
); | ||
} | ||
} |
Oops, something went wrong.