mirror of
https://github.com/bggRGjQaUbCoE/PiliPlus.git
synced 2026-06-05 18:44:48 +08:00
@@ -1,6 +1,8 @@
|
|||||||
import 'package:PiliPlus/common/style.dart' as common_style;
|
import 'package:PiliPlus/common/style.dart' as common_style;
|
||||||
import 'package:PiliPlus/models/dynamics/result.dart';
|
import 'package:PiliPlus/models/dynamics/result.dart';
|
||||||
import 'package:PiliPlus/models/dynamics/vote_model.dart';
|
import 'package:PiliPlus/models/dynamics/vote_model.dart';
|
||||||
|
import 'package:PiliPlus/utils/color_utils.dart';
|
||||||
|
import 'package:PiliPlus/utils/parse_int.dart';
|
||||||
|
|
||||||
class ArticleContentModel {
|
class ArticleContentModel {
|
||||||
int? align;
|
int? align;
|
||||||
@@ -124,14 +126,14 @@ class Word {
|
|||||||
|
|
||||||
Word.fromJson(Map<String, dynamic> json) {
|
Word.fromJson(Map<String, dynamic> json) {
|
||||||
words = json['words'];
|
words = json['words'];
|
||||||
fontSize = (json['font_size'] as num?)?.toDouble();
|
if (json['font_size'] case final num rawSize when rawSize != 0) {
|
||||||
|
fontSize = rawSize.toDouble();
|
||||||
|
}
|
||||||
style = json['style'] == null ? null : Style.fromJson(json['style']);
|
style = json['style'] == null ? null : Style.fromJson(json['style']);
|
||||||
color = json['color'] == null
|
if (json['color'] case final String rawColor
|
||||||
? null
|
when rawColor.startsWith('#')) {
|
||||||
: int.tryParse(
|
color = ColourUtils.parse2Int(json['color']);
|
||||||
'FF${(json['color'] as String).substring(1)}',
|
}
|
||||||
radix: 16,
|
|
||||||
);
|
|
||||||
fontLevel = json['font_level'];
|
fontLevel = json['font_level'];
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -275,7 +277,7 @@ class Music {
|
|||||||
|
|
||||||
Music.fromJson(Map<String, dynamic> json) {
|
Music.fromJson(Map<String, dynamic> json) {
|
||||||
cover = json['cover'];
|
cover = json['cover'];
|
||||||
id = json['id'];
|
id = safeToInt(json['id']);
|
||||||
jumpUrl = json['jump_url'];
|
jumpUrl = json['jump_url'];
|
||||||
label = json['label'];
|
label = json['label'];
|
||||||
title = json['title'];
|
title = json['title'];
|
||||||
@@ -291,12 +293,12 @@ class Opus {
|
|||||||
int? statView;
|
int? statView;
|
||||||
|
|
||||||
Opus.fromJson(Map<String, dynamic> json) {
|
Opus.fromJson(Map<String, dynamic> json) {
|
||||||
authorMid = json['author']?['mid'];
|
authorMid = safeToInt(json['author']?['mid']);
|
||||||
authorName = json['author']?['name'];
|
authorName = json['author']?['name'];
|
||||||
cover = json['cover'];
|
cover = json['cover'];
|
||||||
jumpUrl = json['jump_url'];
|
jumpUrl = json['jump_url'];
|
||||||
title = json['title'];
|
title = json['title'];
|
||||||
statView = json['stat']?['view'];
|
statView = safeToInt(json['stat']?['view']);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -317,9 +319,9 @@ class Live {
|
|||||||
descSecond = json['desc_second'];
|
descSecond = json['desc_second'];
|
||||||
title = json['title'];
|
title = json['title'];
|
||||||
jumpUrl = json['jump_url'];
|
jumpUrl = json['jump_url'];
|
||||||
id = json['id'];
|
id = safeToInt(json['id']);
|
||||||
liveState = json['live_state'];
|
liveState = safeToInt(json['live_state']);
|
||||||
reserveType = json['reserve_type'];
|
reserveType = safeToInt(json['reserve_type']);
|
||||||
badgeText = json['badge']?['text'];
|
badgeText = json['badge']?['text'];
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,4 +1,5 @@
|
|||||||
import 'package:PiliPlus/utils/extension/iterable_ext.dart';
|
import 'package:PiliPlus/utils/extension/iterable_ext.dart';
|
||||||
|
import 'package:PiliPlus/utils/parse_int.dart';
|
||||||
|
|
||||||
class SimpleVoteInfo {
|
class SimpleVoteInfo {
|
||||||
int? choiceCnt;
|
int? choiceCnt;
|
||||||
@@ -22,14 +23,14 @@ class SimpleVoteInfo {
|
|||||||
});
|
});
|
||||||
|
|
||||||
SimpleVoteInfo.fromJson(Map<String, dynamic> json) {
|
SimpleVoteInfo.fromJson(Map<String, dynamic> json) {
|
||||||
choiceCnt = json['choice_cnt'];
|
choiceCnt = safeToInt(json['choice_cnt']);
|
||||||
defaultShare = json['default_share'];
|
defaultShare = safeToInt(json['default_share']);
|
||||||
desc = json['desc'];
|
desc = json['desc'];
|
||||||
endTime = json['end_time'];
|
endTime = safeToInt(json['end_time']);
|
||||||
status = json['status'];
|
status = safeToInt(json['status']);
|
||||||
uid = json['uid'];
|
uid = safeToInt(json['uid']);
|
||||||
voteId = json['vote_id'];
|
voteId = safeToInt(json['vote_id']);
|
||||||
joinNum = json['join_num'] ?? 0;
|
joinNum = safeToInt(json['join_num']) ?? 0;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -260,7 +260,7 @@ class OpusContent extends StatelessWidget {
|
|||||||
.toList(),
|
.toList(),
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
case 3 when (element.line != null):
|
case 3 when (element.line?.pic != null):
|
||||||
final height = element.line!.pic!.height?.toDouble();
|
final height = element.line!.pic!.height?.toDouble();
|
||||||
return CachedNetworkImage(
|
return CachedNetworkImage(
|
||||||
fit: .contain,
|
fit: .contain,
|
||||||
@@ -336,6 +336,8 @@ class OpusContent extends StatelessWidget {
|
|||||||
Text(ugc.title!),
|
Text(ugc.title!),
|
||||||
Text(
|
Text(
|
||||||
ugc.descSecond!,
|
ugc.descSecond!,
|
||||||
|
maxLines: 2,
|
||||||
|
overflow: .ellipsis,
|
||||||
style: TextStyle(
|
style: TextStyle(
|
||||||
fontSize: 13,
|
fontSize: 13,
|
||||||
color: colorScheme.outline,
|
color: colorScheme.outline,
|
||||||
@@ -378,6 +380,8 @@ class OpusContent extends StatelessWidget {
|
|||||||
if (common.desc2 != null)
|
if (common.desc2 != null)
|
||||||
Text(
|
Text(
|
||||||
common.desc2!,
|
common.desc2!,
|
||||||
|
maxLines: 2,
|
||||||
|
overflow: .ellipsis,
|
||||||
style: TextStyle(
|
style: TextStyle(
|
||||||
fontSize: 13,
|
fontSize: 13,
|
||||||
color: colorScheme.outline,
|
color: colorScheme.outline,
|
||||||
@@ -415,6 +419,8 @@ class OpusContent extends StatelessWidget {
|
|||||||
if (live.descSecond != null)
|
if (live.descSecond != null)
|
||||||
Text(
|
Text(
|
||||||
live.descSecond!,
|
live.descSecond!,
|
||||||
|
maxLines: 2,
|
||||||
|
overflow: .ellipsis,
|
||||||
style: TextStyle(
|
style: TextStyle(
|
||||||
fontSize: 13,
|
fontSize: 13,
|
||||||
color: colorScheme.outline,
|
color: colorScheme.outline,
|
||||||
@@ -507,6 +513,8 @@ class OpusContent extends StatelessWidget {
|
|||||||
if (music.label != null)
|
if (music.label != null)
|
||||||
Text(
|
Text(
|
||||||
music.label!,
|
music.label!,
|
||||||
|
maxLines: 2,
|
||||||
|
overflow: .ellipsis,
|
||||||
style: TextStyle(
|
style: TextStyle(
|
||||||
fontSize: 13,
|
fontSize: 13,
|
||||||
color: colorScheme.outline,
|
color: colorScheme.outline,
|
||||||
@@ -693,9 +701,9 @@ class OpusContent extends StatelessWidget {
|
|||||||
),
|
),
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
} catch (e) {
|
} catch (e, s) {
|
||||||
return SelectableText(
|
return SelectableText(
|
||||||
'错误的类型 $e',
|
'错误的类型 $e${kDebugMode ? '\n$s' : ''}',
|
||||||
style: const TextStyle(
|
style: const TextStyle(
|
||||||
fontWeight: .bold,
|
fontWeight: .bold,
|
||||||
color: Colors.red,
|
color: Colors.red,
|
||||||
|
|||||||
@@ -1,8 +1,10 @@
|
|||||||
import 'package:flutter/rendering.dart' show Color;
|
import 'package:flutter/rendering.dart' show Color;
|
||||||
|
|
||||||
abstract final class ColourUtils {
|
abstract final class ColourUtils {
|
||||||
static Color parseColor(String color) =>
|
static int parse2Int(String color) =>
|
||||||
Color(0xFF000000 | int.parse(color.substring(1), radix: 16));
|
0xFF000000 | int.parse(color.substring(1), radix: 16);
|
||||||
|
|
||||||
|
static Color parseColor(String color) => Color(parse2Int(color));
|
||||||
|
|
||||||
static Color parseMedalColor(String color) {
|
static Color parseMedalColor(String color) {
|
||||||
final rgba = int.parse(color.substring(1), radix: 16);
|
final rgba = int.parse(color.substring(1), radix: 16);
|
||||||
|
|||||||
Reference in New Issue
Block a user