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 path;
late String fileServer;
PicaImage.fromJson(Map<String, dynamic> json) {
OssImage.fromJson(Map<String, dynamic> 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<String> characters;
late PicaImage avatar;
late OssImage avatar;
BasicUser.fromJson(Map<String, dynamic> 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<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 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<String> categories;
late PicaImage thumb;
late OssImage thumb;
late int likesCount;
ComicSimple.fromJson(Map<String, dynamic> json) {
@ -121,7 +121,7 @@ class ComicSimple {
this.epsCount = json["epsCount"];
this.finished = json["finished"];
this.categories = List<String>.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<String, dynamic> 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<PicaImage> screenshots;
late List<OssImage> 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<String, dynamic>.of(e))
.map((e) => PicaImage.fromJson(e))
.map((e) => OssImage.fromJson(e))
.toList();
this.commentsCount = json["commentsCount"];
this.downloadsCount = json["downloadsCount"];

View File

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

View File

@ -54,8 +54,6 @@ class _GameInfoScreenState extends State<GameInfoScreen> {
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<GameInfoScreen> {
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<GameInfoScreen> {
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('下载'),
),
),
),
],
),
);

View File

@ -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<StatefulWidget> createState() => _PicaAvatarState();
State<StatefulWidget> createState() => _AvatarState();
}
class _PicaAvatarState extends State<PicaAvatar> {
class _AvatarState extends State<Avatar> {
late Future<String> _future = _load();
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/Method.dart';
import 'PicaAvatar.dart';
import 'Avatar.dart';
class ComicCommentItem extends StatefulWidget {
final String comicId;
@ -49,7 +49,7 @@ class _ComicCommentItem extends State<ComicCommentItem> {
child: Row(
crossAxisAlignment: CrossAxisAlignment.start,
children: [
PicaAvatar(comment.user.avatar),
Avatar(comment.user.avatar),
Container(width: 5),
Expanded(
child: Column(

View File

@ -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,
),
]
: [],
],
),
),
],
);
}

View File

@ -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<UserProfileCard> {
child: Column(
children: [
Expanded(child: Container()),
PicaAvatar(profile.avatar),
Avatar(profile.avatar),
Container(width: 18),
Text(
profile.name,