From 1011621f090db75f4d8cec0731eedf969964d97e Mon Sep 17 00:00:00 2001 From: niuhuan Date: Tue, 9 Nov 2021 10:38:04 +0800 Subject: [PATCH] game info screen layout --- lib/basic/Entities.dart | 28 +++---- lib/screens/ComicReaderScreen.dart | 8 +- lib/screens/GameInfoScreen.dart | 74 +++++-------------- .../{PicaAvatar.dart => Avatar.dart} | 10 +-- lib/screens/components/ComicCommentItem.dart | 4 +- lib/screens/components/GameTitleCard.dart | 39 ++++++++++ lib/screens/components/UserProfileCard.dart | 4 +- 7 files changed, 85 insertions(+), 82 deletions(-) rename lib/screens/components/{PicaAvatar.dart => Avatar.dart} (88%) diff --git a/lib/basic/Entities.dart b/lib/basic/Entities.dart index 66634ee..a72daf2 100644 --- a/lib/basic/Entities.dart +++ b/lib/basic/Entities.dart @@ -1,10 +1,10 @@ /// 图片 -class PicaImage { +class OssImage { late String originalName; late String path; late String fileServer; - PicaImage.fromJson(Map json) { + OssImage.fromJson(Map json) { this.originalName = json["originalName"]; this.path = json["path"]; this.fileServer = json["fileServer"]; @@ -21,7 +21,7 @@ class BasicUser { late int exp; late int level; late List characters; - late PicaImage avatar; + late OssImage avatar; BasicUser.fromJson(Map json) { this.id = json["_id"]; @@ -34,7 +34,7 @@ class BasicUser { this.characters = json["characters"] == null ? [] : List.of(json["characters"]).map((e) => "$e").toList(); - this.avatar = PicaImage.fromJson(Map.of(json["avatar"])); + this.avatar = OssImage.fromJson(Map.of(json["avatar"])); } } @@ -73,7 +73,7 @@ class Category { late String id; late String title; late String description; - late PicaImage thumb; + late OssImage thumb; late bool isWeb; late bool active; late String link; @@ -82,7 +82,7 @@ class Category { this.id = json["_id"]; this.title = json["title"]; this.description = json["description"]; - this.thumb = PicaImage.fromJson(json["thumb"]); + this.thumb = OssImage.fromJson(json["thumb"]); this.isWeb = json["isWeb"]; this.active = json["active"]; this.link = json["link"]; @@ -110,7 +110,7 @@ class ComicSimple { late int epsCount; late bool finished; late List categories; - late PicaImage thumb; + late OssImage thumb; late int likesCount; ComicSimple.fromJson(Map json) { @@ -121,7 +121,7 @@ class ComicSimple { this.epsCount = json["epsCount"]; this.finished = json["finished"]; this.categories = List.from(json["categories"]); - this.thumb = PicaImage.fromJson(json["thumb"]); + this.thumb = OssImage.fromJson(json["thumb"]); this.likesCount = json["likesCount"]; } } @@ -210,11 +210,11 @@ class PicturePage extends Page { /// 漫画图片信息 class Picture { late String id; - late PicaImage media; + late OssImage media; Picture.fromJson(Map json) { this.id = json["_id"]; - this.media = PicaImage.fromJson(json["media"]); + this.media = OssImage.fromJson(json["media"]); } } @@ -487,7 +487,7 @@ class GameSimple { late String id; late String title; late String version; - late PicaImage icon; + late OssImage icon; late String publisher; late bool adult; late bool suggest; @@ -499,7 +499,7 @@ class GameSimple { this.id = json["_id"]; this.title = json["title"]; this.version = json["version"]; - this.icon = PicaImage.fromJson(json["icon"]); + this.icon = OssImage.fromJson(json["icon"]); this.publisher = json["publisher"]; this.adult = json["adult"]; this.suggest = json["suggest"]; @@ -514,7 +514,7 @@ class GameInfo extends GameSimple { late String description; late String updateContent; late String videoLink; - late List screenshots; + late List screenshots; late int commentsCount; late int downloadsCount; late bool isLiked; @@ -531,7 +531,7 @@ class GameInfo extends GameSimple { this.videoLink = json["videoLink"]; this.screenshots = List.of(json["screenshots"]) .map((e) => Map.of(e)) - .map((e) => PicaImage.fromJson(e)) + .map((e) => OssImage.fromJson(e)) .toList(); this.commentsCount = json["commentsCount"]; this.downloadsCount = json["downloadsCount"]; diff --git a/lib/screens/ComicReaderScreen.dart b/lib/screens/ComicReaderScreen.dart index 0589735..ecdb973 100644 --- a/lib/screens/ComicReaderScreen.dart +++ b/lib/screens/ComicReaderScreen.dart @@ -40,15 +40,15 @@ class ComicReaderScreen extends StatefulWidget { class _ComicReaderScreenState extends State { late Ep _ep; late bool _fullScreen = false; - late Future> _future; + late Future> _future; int? _lastChangeRank; bool _replacement = false; - Future> _load() async { + Future> _load() async { if (widget.initPictureRank == null) { await method.storeViewEp(widget.comicInfo.id, _ep.order, _ep.title, 1); } - List list = []; + List list = []; var _needLoadPage = 0; late PicturePage page; do { @@ -165,7 +165,7 @@ class _ComicReaderScreenState extends State { }); }, successBuilder: - (BuildContext context, AsyncSnapshot> snapshot) { + (BuildContext context, AsyncSnapshot> snapshot) { return ImageReader( ImageReaderStruct( images: snapshot.data! diff --git a/lib/screens/GameInfoScreen.dart b/lib/screens/GameInfoScreen.dart index 370dd09..0335ddd 100644 --- a/lib/screens/GameInfoScreen.dart +++ b/lib/screens/GameInfoScreen.dart @@ -54,8 +54,6 @@ class _GameInfoScreenState extends State { BorderRadius iconRadius = BorderRadius.all(Radius.circular(6)); double screenShootMargin = 10; double screenShootHeight = 200; - double platformMargin = 10; - double platformSize = 25; TextStyle descriptionStyle = TextStyle(); return LayoutBuilder( @@ -69,44 +67,26 @@ class _GameInfoScreenState extends State { children: [ GameTitleCard(info), Container( - height: platformSize, - margin: EdgeInsets.only(bottom: platformMargin), - child: ListView( - padding: EdgeInsets.only( - left: platformMargin, - right: platformMargin, + padding: EdgeInsets.only( + left: 20, right: 20, top: 5, bottom: 10, + ), + child: ClipRRect( + borderRadius: BorderRadius.all(Radius.circular(5)), + child: MaterialButton( + color: Theme.of(context).colorScheme.secondary, + textColor: Colors.white, + onPressed: () { + Navigator.push( + context, + MaterialPageRoute( + builder: (context) => GameDownloadScreen(info)), + ); + }, + child: Container( + padding: EdgeInsets.all(5), + child: Text('下载'), + ), ), - scrollDirection: Axis.horizontal, - children: [ - ...info.android - ? [ - Container( - width: platformMargin, - ), - SvgPicture.asset( - 'lib/assets/android.svg', - fit: BoxFit.contain, - width: platformSize, - height: platformSize, - color: Colors.green.shade500, - ), - ] - : [], - ...info.ios - ? [ - Container( - width: platformMargin, - ), - SvgPicture.asset( - 'lib/assets/apple.svg', - fit: BoxFit.contain, - width: platformSize, - height: platformSize, - color: Colors.grey.shade500, - ), - ] - : [], - ], ), ), Container( @@ -143,22 +123,6 @@ class _GameInfoScreenState extends State { padding: EdgeInsets.all(20), child: Text(info.description, style: descriptionStyle), ), - Container( - color: Colors.grey.shade500.withOpacity(.1), - child: MaterialButton( - onPressed: () { - Navigator.push( - context, - MaterialPageRoute( - builder: (context) => GameDownloadScreen(info)), - ); - }, - child: Container( - padding: EdgeInsets.all(30), - child: Text('下载'), - ), - ), - ), ], ), ); diff --git a/lib/screens/components/PicaAvatar.dart b/lib/screens/components/Avatar.dart similarity index 88% rename from lib/screens/components/PicaAvatar.dart rename to lib/screens/components/Avatar.dart index c12c9c1..006f27b 100644 --- a/lib/screens/components/PicaAvatar.dart +++ b/lib/screens/components/Avatar.dart @@ -8,17 +8,17 @@ const double _avatarMargin = 5; const double _avatarBorderSize = 1.5; // 头像 -class PicaAvatar extends StatefulWidget { - final PicaImage avatarImage; +class Avatar extends StatefulWidget { + final OssImage avatarImage; final double size; - const PicaAvatar(this.avatarImage, {this.size = 50}); + const Avatar(this.avatarImage, {this.size = 50}); @override - State createState() => _PicaAvatarState(); + State createState() => _AvatarState(); } -class _PicaAvatarState extends State { +class _AvatarState extends State { late Future _future = _load(); Future _load() async { diff --git a/lib/screens/components/ComicCommentItem.dart b/lib/screens/components/ComicCommentItem.dart index 1d4e1d8..1530ca1 100644 --- a/lib/screens/components/ComicCommentItem.dart +++ b/lib/screens/components/ComicCommentItem.dart @@ -3,7 +3,7 @@ import 'package:pikapi/basic/Common.dart'; import 'package:pikapi/basic/Entities.dart'; import 'package:pikapi/basic/Method.dart'; -import 'PicaAvatar.dart'; +import 'Avatar.dart'; class ComicCommentItem extends StatefulWidget { final String comicId; @@ -49,7 +49,7 @@ class _ComicCommentItem extends State { child: Row( crossAxisAlignment: CrossAxisAlignment.start, children: [ - PicaAvatar(comment.user.avatar), + Avatar(comment.user.avatar), Container(width: 5), Expanded( child: Column( diff --git a/lib/screens/components/GameTitleCard.dart b/lib/screens/components/GameTitleCard.dart index 3aad090..670022c 100644 --- a/lib/screens/components/GameTitleCard.dart +++ b/lib/screens/components/GameTitleCard.dart @@ -1,4 +1,5 @@ import 'package:flutter/material.dart'; +import 'package:flutter_svg/svg.dart'; import 'package:pikapi/basic/Entities.dart'; import 'Images.dart'; @@ -22,6 +23,8 @@ class GameTitleCard extends StatelessWidget { TextStyle versionStyle = TextStyle( fontSize: 12.5, ); + double platformMargin = 10; + double platformSize = 25; return Row( children: [ Container( @@ -48,6 +51,42 @@ class GameTitleCard extends StatelessWidget { ], ), ), + Container( + margin: EdgeInsets.only(right: iconMargin), + // padding: EdgeInsets.only( + // left: platformMargin, + // right: platformMargin, + // ), + child: Column( + children: [ + ...info.android + ? [ + SvgPicture.asset( + 'lib/assets/android.svg', + fit: BoxFit.contain, + width: platformSize, + height: platformSize, + color: Colors.green.shade500, + ), + ] + : [], + Container( + height: platformMargin, + ), + ...info.ios + ? [ + SvgPicture.asset( + 'lib/assets/apple.svg', + fit: BoxFit.contain, + width: platformSize, + height: platformSize, + color: Colors.grey.shade500, + ), + ] + : [], + ], + ), + ), ], ); } diff --git a/lib/screens/components/UserProfileCard.dart b/lib/screens/components/UserProfileCard.dart index 52ccd29..30c46a4 100644 --- a/lib/screens/components/UserProfileCard.dart +++ b/lib/screens/components/UserProfileCard.dart @@ -4,7 +4,7 @@ import 'package:flutter/material.dart'; import 'package:pikapi/basic/Common.dart'; import 'package:pikapi/basic/Entities.dart'; import 'package:pikapi/screens/components/ItemBuilder.dart'; -import 'package:pikapi/screens/components/PicaAvatar.dart'; +import 'package:pikapi/screens/components/Avatar.dart'; import 'package:pikapi/screens/components/Images.dart'; import 'package:pikapi/basic/Method.dart'; @@ -86,7 +86,7 @@ class _UserProfileCardState extends State { child: Column( children: [ Expanded(child: Container()), - PicaAvatar(profile.avatar), + Avatar(profile.avatar), Container(width: 18), Text( profile.name,