game info screen layout

This commit is contained in:
niuhuan 2021-11-09 10:38:04 +08:00
parent 7caad393c2
commit 1011621f09
7 changed files with 85 additions and 82 deletions

View File

@ -1,10 +1,10 @@
/// ///
class PicaImage { class OssImage {
late String originalName; late String originalName;
late String path; late String path;
late String fileServer; late String fileServer;
PicaImage.fromJson(Map<String, dynamic> json) { OssImage.fromJson(Map<String, dynamic> json) {
this.originalName = json["originalName"]; this.originalName = json["originalName"];
this.path = json["path"]; this.path = json["path"];
this.fileServer = json["fileServer"]; this.fileServer = json["fileServer"];
@ -21,7 +21,7 @@ class BasicUser {
late int exp; late int exp;
late int level; late int level;
late List<String> characters; late List<String> characters;
late PicaImage avatar; late OssImage avatar;
BasicUser.fromJson(Map<String, dynamic> json) { BasicUser.fromJson(Map<String, dynamic> json) {
this.id = json["_id"]; this.id = json["_id"];
@ -34,7 +34,7 @@ class BasicUser {
this.characters = json["characters"] == null this.characters = json["characters"] == null
? [] ? []
: List.of(json["characters"]).map((e) => "$e").toList(); : List.of(json["characters"]).map((e) => "$e").toList();
this.avatar = PicaImage.fromJson(Map<String, dynamic>.of(json["avatar"])); this.avatar = OssImage.fromJson(Map<String, dynamic>.of(json["avatar"]));
} }
} }
@ -73,7 +73,7 @@ class Category {
late String id; late String id;
late String title; late String title;
late String description; late String description;
late PicaImage thumb; late OssImage thumb;
late bool isWeb; late bool isWeb;
late bool active; late bool active;
late String link; late String link;
@ -82,7 +82,7 @@ class Category {
this.id = json["_id"]; this.id = json["_id"];
this.title = json["title"]; this.title = json["title"];
this.description = json["description"]; this.description = json["description"];
this.thumb = PicaImage.fromJson(json["thumb"]); this.thumb = OssImage.fromJson(json["thumb"]);
this.isWeb = json["isWeb"]; this.isWeb = json["isWeb"];
this.active = json["active"]; this.active = json["active"];
this.link = json["link"]; this.link = json["link"];
@ -110,7 +110,7 @@ class ComicSimple {
late int epsCount; late int epsCount;
late bool finished; late bool finished;
late List<String> categories; late List<String> categories;
late PicaImage thumb; late OssImage thumb;
late int likesCount; late int likesCount;
ComicSimple.fromJson(Map<String, dynamic> json) { ComicSimple.fromJson(Map<String, dynamic> json) {
@ -121,7 +121,7 @@ class ComicSimple {
this.epsCount = json["epsCount"]; this.epsCount = json["epsCount"];
this.finished = json["finished"]; this.finished = json["finished"];
this.categories = List<String>.from(json["categories"]); this.categories = List<String>.from(json["categories"]);
this.thumb = PicaImage.fromJson(json["thumb"]); this.thumb = OssImage.fromJson(json["thumb"]);
this.likesCount = json["likesCount"]; this.likesCount = json["likesCount"];
} }
} }
@ -210,11 +210,11 @@ class PicturePage extends Page {
/// ///
class Picture { class Picture {
late String id; late String id;
late PicaImage media; late OssImage media;
Picture.fromJson(Map<String, dynamic> json) { Picture.fromJson(Map<String, dynamic> json) {
this.id = json["_id"]; 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 id;
late String title; late String title;
late String version; late String version;
late PicaImage icon; late OssImage icon;
late String publisher; late String publisher;
late bool adult; late bool adult;
late bool suggest; late bool suggest;
@ -499,7 +499,7 @@ class GameSimple {
this.id = json["_id"]; this.id = json["_id"];
this.title = json["title"]; this.title = json["title"];
this.version = json["version"]; this.version = json["version"];
this.icon = PicaImage.fromJson(json["icon"]); this.icon = OssImage.fromJson(json["icon"]);
this.publisher = json["publisher"]; this.publisher = json["publisher"];
this.adult = json["adult"]; this.adult = json["adult"];
this.suggest = json["suggest"]; this.suggest = json["suggest"];
@ -514,7 +514,7 @@ class GameInfo extends GameSimple {
late String description; late String description;
late String updateContent; late String updateContent;
late String videoLink; late String videoLink;
late List<PicaImage> screenshots; late List<OssImage> screenshots;
late int commentsCount; late int commentsCount;
late int downloadsCount; late int downloadsCount;
late bool isLiked; late bool isLiked;
@ -531,7 +531,7 @@ class GameInfo extends GameSimple {
this.videoLink = json["videoLink"]; this.videoLink = json["videoLink"];
this.screenshots = List.of(json["screenshots"]) this.screenshots = List.of(json["screenshots"])
.map((e) => Map<String, dynamic>.of(e)) .map((e) => Map<String, dynamic>.of(e))
.map((e) => PicaImage.fromJson(e)) .map((e) => OssImage.fromJson(e))
.toList(); .toList();
this.commentsCount = json["commentsCount"]; this.commentsCount = json["commentsCount"];
this.downloadsCount = json["downloadsCount"]; this.downloadsCount = json["downloadsCount"];

View File

@ -40,15 +40,15 @@ class ComicReaderScreen extends StatefulWidget {
class _ComicReaderScreenState extends State<ComicReaderScreen> { class _ComicReaderScreenState extends State<ComicReaderScreen> {
late Ep _ep; late Ep _ep;
late bool _fullScreen = false; late bool _fullScreen = false;
late Future<List<PicaImage>> _future; late Future<List<OssImage>> _future;
int? _lastChangeRank; int? _lastChangeRank;
bool _replacement = false; bool _replacement = false;
Future<List<PicaImage>> _load() async { Future<List<OssImage>> _load() async {
if (widget.initPictureRank == null) { if (widget.initPictureRank == null) {
await method.storeViewEp(widget.comicInfo.id, _ep.order, _ep.title, 1); await method.storeViewEp(widget.comicInfo.id, _ep.order, _ep.title, 1);
} }
List<PicaImage> list = []; List<OssImage> list = [];
var _needLoadPage = 0; var _needLoadPage = 0;
late PicturePage page; late PicturePage page;
do { do {
@ -165,7 +165,7 @@ class _ComicReaderScreenState extends State<ComicReaderScreen> {
}); });
}, },
successBuilder: successBuilder:
(BuildContext context, AsyncSnapshot<List<PicaImage>> snapshot) { (BuildContext context, AsyncSnapshot<List<OssImage>> snapshot) {
return ImageReader( return ImageReader(
ImageReaderStruct( ImageReaderStruct(
images: snapshot.data! images: snapshot.data!

View File

@ -54,8 +54,6 @@ class _GameInfoScreenState extends State<GameInfoScreen> {
BorderRadius iconRadius = BorderRadius.all(Radius.circular(6)); BorderRadius iconRadius = BorderRadius.all(Radius.circular(6));
double screenShootMargin = 10; double screenShootMargin = 10;
double screenShootHeight = 200; double screenShootHeight = 200;
double platformMargin = 10;
double platformSize = 25;
TextStyle descriptionStyle = TextStyle(); TextStyle descriptionStyle = TextStyle();
return LayoutBuilder( return LayoutBuilder(
@ -69,44 +67,26 @@ class _GameInfoScreenState extends State<GameInfoScreen> {
children: [ children: [
GameTitleCard(info), GameTitleCard(info),
Container( Container(
height: platformSize,
margin: EdgeInsets.only(bottom: platformMargin),
child: ListView(
padding: EdgeInsets.only( padding: EdgeInsets.only(
left: platformMargin, left: 20, right: 20, top: 5, bottom: 10,
right: platformMargin,
), ),
scrollDirection: Axis.horizontal, child: ClipRRect(
children: [ borderRadius: BorderRadius.all(Radius.circular(5)),
...info.android child: MaterialButton(
? [ color: Theme.of(context).colorScheme.secondary,
Container( textColor: Colors.white,
width: platformMargin, onPressed: () {
Navigator.push(
context,
MaterialPageRoute(
builder: (context) => GameDownloadScreen(info)),
);
},
child: Container(
padding: EdgeInsets.all(5),
child: Text('下载'),
), ),
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( Container(
@ -143,22 +123,6 @@ class _GameInfoScreenState extends State<GameInfoScreen> {
padding: EdgeInsets.all(20), padding: EdgeInsets.all(20),
child: Text(info.description, style: descriptionStyle), 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('下载'),
),
),
),
], ],
), ),
); );

View File

@ -8,17 +8,17 @@ const double _avatarMargin = 5;
const double _avatarBorderSize = 1.5; const double _avatarBorderSize = 1.5;
// //
class PicaAvatar extends StatefulWidget { class Avatar extends StatefulWidget {
final PicaImage avatarImage; final OssImage avatarImage;
final double size; final double size;
const PicaAvatar(this.avatarImage, {this.size = 50}); const Avatar(this.avatarImage, {this.size = 50});
@override @override
State<StatefulWidget> createState() => _PicaAvatarState(); State<StatefulWidget> createState() => _AvatarState();
} }
class _PicaAvatarState extends State<PicaAvatar> { class _AvatarState extends State<Avatar> {
late Future<String> _future = _load(); late Future<String> _future = _load();
Future<String> _load() async { Future<String> _load() async {

View File

@ -3,7 +3,7 @@ import 'package:pikapi/basic/Common.dart';
import 'package:pikapi/basic/Entities.dart'; import 'package:pikapi/basic/Entities.dart';
import 'package:pikapi/basic/Method.dart'; import 'package:pikapi/basic/Method.dart';
import 'PicaAvatar.dart'; import 'Avatar.dart';
class ComicCommentItem extends StatefulWidget { class ComicCommentItem extends StatefulWidget {
final String comicId; final String comicId;
@ -49,7 +49,7 @@ class _ComicCommentItem extends State<ComicCommentItem> {
child: Row( child: Row(
crossAxisAlignment: CrossAxisAlignment.start, crossAxisAlignment: CrossAxisAlignment.start,
children: [ children: [
PicaAvatar(comment.user.avatar), Avatar(comment.user.avatar),
Container(width: 5), Container(width: 5),
Expanded( Expanded(
child: Column( child: Column(

View File

@ -1,4 +1,5 @@
import 'package:flutter/material.dart'; import 'package:flutter/material.dart';
import 'package:flutter_svg/svg.dart';
import 'package:pikapi/basic/Entities.dart'; import 'package:pikapi/basic/Entities.dart';
import 'Images.dart'; import 'Images.dart';
@ -22,6 +23,8 @@ class GameTitleCard extends StatelessWidget {
TextStyle versionStyle = TextStyle( TextStyle versionStyle = TextStyle(
fontSize: 12.5, fontSize: 12.5,
); );
double platformMargin = 10;
double platformSize = 25;
return Row( return Row(
children: [ children: [
Container( 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,
),
]
: [],
],
),
),
], ],
); );
} }

View File

@ -4,7 +4,7 @@ import 'package:flutter/material.dart';
import 'package:pikapi/basic/Common.dart'; import 'package:pikapi/basic/Common.dart';
import 'package:pikapi/basic/Entities.dart'; import 'package:pikapi/basic/Entities.dart';
import 'package:pikapi/screens/components/ItemBuilder.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/screens/components/Images.dart';
import 'package:pikapi/basic/Method.dart'; import 'package:pikapi/basic/Method.dart';
@ -86,7 +86,7 @@ class _UserProfileCardState extends State<UserProfileCard> {
child: Column( child: Column(
children: [ children: [
Expanded(child: Container()), Expanded(child: Container()),
PicaAvatar(profile.avatar), Avatar(profile.avatar),
Container(width: 18), Container(width: 18),
Text( Text(
profile.name, profile.name,