diff --git a/lib/ProgressDotsBar.dart b/lib/ProgressDotsBar.dart index bd0eb35..6585226 100644 --- a/lib/ProgressDotsBar.dart +++ b/lib/ProgressDotsBar.dart @@ -21,18 +21,18 @@ class _ProgressDotState extends State void updateDotsState(currentId) { if (currentId > widget.questionId) { setState(() { - _size = 20; + _size = 32; // _color = Colors.lightGreen; }); } else if (currentId == widget.questionId) { setState(() { - _size = 40; + _size = 56; _animationChange(); // _color = Colors.lightGreen; }); } else if (currentId < widget.questionId) { setState(() { - _size = 20; + _size = 32; // _color = Colors.grey; }); } @@ -119,12 +119,15 @@ class ProgressDotsBar extends StatefulWidget { class _ProgressDotsBarState extends State { Widget line() { - return Container( - height: 3, - width: 10, - decoration: const BoxDecoration( - shape: BoxShape.rectangle, - color: Colors.grey, + return Padding( + padding: const EdgeInsets.all(8.0), + child: Container( + height: 3, + width: 10, + decoration: const BoxDecoration( + shape: BoxShape.rectangle, + color: Color(0xff220f60), + ), ), ); } @@ -139,8 +142,10 @@ class _ProgressDotsBarState extends State { @override Widget build(BuildContext context) { - return Container( + return Padding( + padding: EdgeInsets.all(24), child: Row( + mainAxisAlignment: MainAxisAlignment.center, children: [ ProgressDot(questionId: 0), line(), diff --git a/lib/model/api.dart b/lib/model/api.dart index f72ac1b..a1ff70b 100644 --- a/lib/model/api.dart +++ b/lib/model/api.dart @@ -32,7 +32,8 @@ void getGameId() async { // print(gameId); QuestionData.gameId = gameId; } -Future questionPost(int num) async{ + +Future questionPost(int num) async { http.Response response; var url = Uri.parse('https://quiet-eyrie-21766.herokuapp.com/question'); Map headers = {'content-type': 'application/json'}; @@ -58,11 +59,11 @@ Future getQuestion() async { await Future.delayed(Duration(microseconds: 20)); print("wait"); } - List> future=[]; + List> future = []; for (int i = 1; i <= 6; i++) { future.add(questionPost(i)); } - var futureAll =Future.wait(future); + var futureAll = Future.wait(future); futureAll.then((results) => controller.sink.add(true)); } @@ -123,39 +124,23 @@ Future getResult() async { var rankingData = data["ranking"]; // 要素分割してリストにする - int circlerank = rankingData[0]["circlerank"]; - String circle_name = jsonDecode(rankingData[0]["circle_name"]); - double percent = rankingData[0]["percent"]; + int circle_ranking = i + 1; + String circle_name = jsonDecode(rankingData[i]["circle_name"]); + double percent = rankingData[i]["percent"]; print(percent); - String circle_image_url = jsonDecode(rankingData[0]["circle_image_url"]); + String circle_image_url = jsonDecode(rankingData[i]["circle_image_url"]); String circle_description = - jsonDecode(rankingData[0]["circle_description"]); - - // var jsonsentence = json.encode(rankingData); - // var utf8sentence = utf8.decode(jsonsentence.runes.toList()); - // print(utf8sentence); - // print(rankingData); - - // String image = rankingData[0]["circle_image_url"]; - // print(image); - - // int circlerank = utf8sentence[0]["circlerank"]; - // String circlename = rankingData[0]["circlename"]; - // double percent = rankingData[0]["percent"]; - // String circle_image_url = rankingData[0]["circle_image_url"]; - // String circle_description = rankingData[0]["circle_description"]; - - // int circlerank = 1; - // String circlename = "cistLT"; - // double percent = 0.3333333333333333; - // String circle_image_url = - // "http://www.itagaki.net/pc/imagefile/memo_0043/photo008.jpg"; - // String circle_description = - // "IT技術系の勉強をしています!初心者大歓迎です!所属メンバーはバイオ系、電子工学系、情報工学系と様々なメンバーで構成されています!!みんなで興味のあることを勉強し、アウトプットすることを目標にしています!一人で悩まないで!一緒に技術力を高めませんか??"; + jsonDecode(rankingData[i]["circle_description"]); + ResultData().set( i, - Result(circlerank, circle_name, percent, circle_image_url, - circle_description)); + Result( + circle_ranking, + circle_name, + percent, + circle_image_url, + circle_description, + )); Resultcontroller.sink.add(true); } diff --git a/lib/resultdata.dart b/lib/resultdata.dart index 64f15bf..8993847 100644 --- a/lib/resultdata.dart +++ b/lib/resultdata.dart @@ -1,12 +1,12 @@ //Questionの情報を持つクラス class Result { - int circlerank; - String circlename; + int circle_ranking; + String circle_name; double percent; String circle_image_url; String circle_description; - Result(this.circlerank, this.circlename, this.percent, this.circle_image_url, - this.circle_description) {} + Result(this.circle_ranking, this.circle_name, this.percent, + this.circle_image_url, this.circle_description) {} } //Singletonでデータをキャッシュする @@ -30,28 +30,37 @@ class ResultData { set(int key, Result value) => _item[key] = value; get(int key) => _item[key]; //サークルを返す - GetCircle(int num){ - if(ResultData().get(num)==null){ + GetCircle(int num) { + if (ResultData().get(num) == null) { return ResultData().get(-1); } return ResultData().get(num); } + //サークル名を返す - GetName(int num){ - return ResultData().get(num).circlename; + GetName(int num) { + return ResultData().get(num).circle_name; } + //画像を返す - GetImage(int num){ + GetImage(int num) { return ResultData().get(num).circle_image_url; } - //説明文を返す - GetDC(int num){ + + //マッチング度を返す + GetDC(int num) { return ResultData().get(num).percent; } + //説明文を返す - Getper(int num){ + Getper(int num) { return ResultData().get(num).circle_description; } + + //順位を返す + GetRank(int num) { + return ResultData().get(num).circle_ranking; + } /* //質問数を返す getlength()=>_item.length; diff --git a/lib/resultpage.dart b/lib/resultpage.dart index cfd9cba..3bdde5d 100644 --- a/lib/resultpage.dart +++ b/lib/resultpage.dart @@ -24,8 +24,8 @@ class _ResultPage extends State { }); } - detailDialog( - context, String imageUrl, String circleName, String introduction) { + detailDialog(context, String imageUrl, String circleName, String introduction, + int circleRanking) { showDialog( context: context, builder: (BuildContext context) => AlertDialog( @@ -66,80 +66,133 @@ class _ResultPage extends State { } Widget firstCard(context, String circleName, double matchingRate, - String introduction, String imageUrl) { + String introduction, String imageUrl, int circleRanking) { return GestureDetector( onTap: () { print('タップされました'); - detailDialog(context, imageUrl, circleName, introduction); + detailDialog( + context, imageUrl, circleName, introduction, circleRanking); }, child: Card( - margin: EdgeInsets.only( - top: 10, - right: 20, - left: 20, - ), - color: Colors.yellow, - child: Column( - children: [ - Align( - alignment: Alignment.topLeft, - child: Stack( - children: [ - Container( - color: Colors.teal, - height: 43, - width: MediaQuery.of(context).size.width * matchingRate, - ), //メーター - - Container( - margin: const EdgeInsets.only(left: 10), - child: Text( - '$circleName', - style: TextStyle( - fontSize: 30, + margin: EdgeInsets.only( + top: 10, + right: 20, + left: 20, + ), + shape: RoundedRectangleBorder( + borderRadius: BorderRadius.circular(5), + ), + color: Theme.of(context).primaryColor, + child: Column( + children: [ + Align( + alignment: Alignment.topLeft, + child: Stack( + children: [ + Container( + padding: const EdgeInsets.all(3.0), + margin: const EdgeInsets.only(left: 80, top: 1), + child: Text( + '$circleName', + style: TextStyle( + color: Colors.white, + fontWeight: FontWeight.bold, + fontSize: 12, + ), ), ), - ), - ], - ), - ), - Container( - color: Colors.lightGreen, - child: Row( - crossAxisAlignment: CrossAxisAlignment.start, - children: [ - Image.network( - imageUrl, - width: 100, - height: 100, - ), - Flexible( - child: Container( + Container( + padding: const EdgeInsets.all(3.0), + margin: const EdgeInsets.only(left: 10, top: 1), + decoration: BoxDecoration( + borderRadius: BorderRadius.circular(30), + color: Colors.white, + ), child: Text( - '$introduction', + '$circleRanking' + "位", style: TextStyle( - fontSize: 15, + color: Theme.of(context).primaryColor, + fontSize: 12, ), ), - color: Colors.lightBlue, - height: 110, ), - ) - ], + Container( + padding: const EdgeInsets.all(3.0), + margin: const EdgeInsets.only(left: 240, top: 1), + decoration: BoxDecoration( + borderRadius: BorderRadius.circular(30), + color: Colors.white, + ), + child: Text( + 'おすすめ度' + (matchingRate.round() * 100).toString() + '%', + style: TextStyle( + color: Theme.of(context).primaryColor, + fontSize: 12, + ), + ), + ), + ], + ), ), - ), - ], - ), - ), + Container( + color: Colors.white, + child: Column( + //パーセントバーと「画像と説明Row」 + children: [ + Padding( + padding: EdgeInsets.only(top: 3.0, bottom: 3.0), + child: PercentageBar( + matchingRate: matchingRate, + ), + ), + Padding( + padding: const EdgeInsets.all(8.0), + child: Row( + crossAxisAlignment: CrossAxisAlignment.start, + children: [ + Align( + alignment: Alignment.topLeft, + child: Stack( + children: [ + Image.network( + imageUrl, + width: 100, + height: 100, + ), + ], + ), + ), + Flexible( + child: Container( + child: Text( + '$introduction', + style: TextStyle( + fontSize: 15, + color: Theme.of(context).primaryColor, + ), + ), + height: 110, + margin: EdgeInsets.only(left: 8.0), + ), + ) + ], + ), + ), + ], + ), + ), + ], + )), ); } Widget secondThirdCard(context, String circleName, double matchingRate, - String introduction, String imageUrl) { + String introduction, String imageUrl, int circleRanking) { return GestureDetector( onTap: () { print('タップされました'); - detailDialog(context, imageUrl, circleName, introduction); + detailDialog( + context, imageUrl, circleName, introduction, circleRanking); }, child: Card( margin: EdgeInsets.only( @@ -177,7 +230,7 @@ class _ResultPage extends State { color: Colors.white, ), child: Text( - '1位', + '$circleRanking' + "位", style: TextStyle( color: Theme.of(context).primaryColor, fontSize: 12, @@ -204,12 +257,14 @@ class _ResultPage extends State { ), Container( color: Colors.white, - child: Column(//パーセントバーと「画像と説明Row」 + child: Column( + //パーセントバーと「画像と説明Row」 children: [ Padding( - padding: EdgeInsets.only(top: 3.0,bottom: 3.0), - child: PercentageBar(matchingRate: matchingRate,), - + padding: EdgeInsets.only(top: 3.0, bottom: 3.0), + child: PercentageBar( + matchingRate: matchingRate, + ), ), Padding( padding: const EdgeInsets.all(8.0), @@ -347,23 +402,27 @@ class _ResultPage extends State { child: Column( children: [ firstCard( - context, - resultLoad(0).circlename, - resultLoad(0).percent, - resultLoad(0).circle_description, - resultLoad(0).circle_image_url), + context, + resultLoad(0).circle_name, + resultLoad(0).percent, + resultLoad(0).circle_description, + resultLoad(0).circle_image_url, + resultLoad(0).circle_ranking, + ), secondThirdCard( context, - resultLoad(1).circlename, + resultLoad(1).circle_name, resultLoad(1).percent, resultLoad(1).circle_description, - resultLoad(1).circle_image_url), + resultLoad(1).circle_image_url, + resultLoad(1).circle_ranking), secondThirdCard( context, - resultLoad(2).circlename, + resultLoad(2).circle_name, resultLoad(2).percent, resultLoad(2).circle_description, - resultLoad(2).circle_image_url) + resultLoad(2).circle_image_url, + resultLoad(2).circle_ranking) ], ), ), @@ -394,27 +453,26 @@ class PercentageBar extends StatelessWidget { required this.matchingRate, }) : super(key: key); final double matchingRate; - int toPercent(double rate){//0~1の少数を0~100の整数に変換 - return (rate * 100).toInt();//切り捨て + int toPercent(double rate) { + //0~1の少数を0~100の整数に変換 + return (rate * 100).toInt(); //切り捨て } + @override Widget build(BuildContext context) { return Stack( children: [ - Container(color:Color(0xff220f60),height: height), + Container(color: Color(0xff220f60), height: height), Container( - decoration: BoxDecoration( - gradient: LinearGradient( - colors: [ - Color(0xff7BD4F1).withOpacity(matchingRate), - Color(0xff7BD4F1).withOpacity(matchingRate), - Color(0xff220f60), - ] - ) + decoration: BoxDecoration( + gradient: LinearGradient(colors: [ + Color(0xff7BD4F1).withOpacity(matchingRate), + Color(0xff7BD4F1).withOpacity(matchingRate), + Color(0xff220f60), + ])), + height: height, ), - height: height, - ), ], ); } -} \ No newline at end of file +}