mirror of
https://github.com/bggRGjQaUbCoE/PiliPlus.git
synced 2026-05-26 11:08:44 +00:00
@@ -1,5 +1,6 @@
|
||||
import 'package:PiliPlus/http/dynamics.dart';
|
||||
import 'package:PiliPlus/http/fav.dart';
|
||||
import 'package:PiliPlus/http/loading_state.dart';
|
||||
import 'package:PiliPlus/http/video.dart';
|
||||
import 'package:PiliPlus/models/dynamics/article_content_model.dart'
|
||||
show ArticleContentModel;
|
||||
@@ -9,6 +10,7 @@ import 'package:PiliPlus/models_new/article/article_info/data.dart';
|
||||
import 'package:PiliPlus/models_new/article/article_view/data.dart';
|
||||
import 'package:PiliPlus/pages/common/dyn/common_dyn_controller.dart';
|
||||
import 'package:PiliPlus/utils/accounts.dart';
|
||||
import 'package:PiliPlus/utils/app_scheme.dart';
|
||||
import 'package:PiliPlus/utils/extension.dart';
|
||||
import 'package:PiliPlus/utils/storage_pref.dart';
|
||||
import 'package:PiliPlus/utils/url_utils.dart';
|
||||
@@ -46,8 +48,9 @@ class ArticleController extends CommonDynController {
|
||||
@override
|
||||
void onInit() {
|
||||
super.onInit();
|
||||
id = Get.parameters['id']!;
|
||||
type = Get.parameters['type']!;
|
||||
final params = Get.parameters;
|
||||
id = params['id']!;
|
||||
type = params['type']!;
|
||||
|
||||
// to opus
|
||||
if (type == 'read') {
|
||||
@@ -55,8 +58,11 @@ class ArticleController extends CommonDynController {
|
||||
url,
|
||||
) {
|
||||
if (url != null) {
|
||||
id = url.split('/').last;
|
||||
type = 'opus';
|
||||
final opusId = PiliScheme.uriDigitRegExp.firstMatch(url)?.group(1);
|
||||
if (opusId != null) {
|
||||
id = opusId;
|
||||
type = 'opus';
|
||||
}
|
||||
}
|
||||
init();
|
||||
});
|
||||
@@ -99,8 +105,10 @@ class ArticleController extends CommonDynController {
|
||||
..author ??= opusData.modules.moduleAuthor
|
||||
..title ??= opusData.modules.moduleTag?.text;
|
||||
return true;
|
||||
} else {
|
||||
loadingState.value = res as Error;
|
||||
return false;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
Future<bool> queryRead(int cvid) async {
|
||||
@@ -116,8 +124,10 @@ class ArticleController extends CommonDynController {
|
||||
getArticleInfo();
|
||||
}
|
||||
return true;
|
||||
} else {
|
||||
loadingState.value = res as Error;
|
||||
return false;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
// stats
|
||||
@@ -208,6 +218,14 @@ class ArticleController extends CommonDynController {
|
||||
SmartDialog.showToast(res['msg']);
|
||||
}
|
||||
}
|
||||
|
||||
@override
|
||||
Future<void> onReload() {
|
||||
if (!isLoaded.value) {
|
||||
return Future.value();
|
||||
}
|
||||
return super.onReload();
|
||||
}
|
||||
}
|
||||
|
||||
class Summary {
|
||||
|
||||
@@ -66,18 +66,15 @@ class _ArticlePageState extends CommonDynPageState<ArticlePage> {
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
final theme = Theme.of(context);
|
||||
final size = MediaQuery.sizeOf(context);
|
||||
final maxWidth = size.width;
|
||||
isPortrait = size.height >= maxWidth;
|
||||
return Scaffold(
|
||||
resizeToAvoidBottomInset: false,
|
||||
appBar: _buildAppBar(isPortrait, maxWidth),
|
||||
appBar: _buildAppBar(),
|
||||
body: Padding(
|
||||
padding: EdgeInsets.only(left: padding.left, right: padding.right),
|
||||
child: Stack(
|
||||
clipBehavior: Clip.none,
|
||||
children: [
|
||||
_buildPage(theme, isPortrait, maxWidth),
|
||||
_buildPage(theme),
|
||||
_buildBottom(theme),
|
||||
],
|
||||
),
|
||||
@@ -85,7 +82,7 @@ class _ArticlePageState extends CommonDynPageState<ArticlePage> {
|
||||
);
|
||||
}
|
||||
|
||||
Widget _buildPage(ThemeData theme, bool isPortrait, double maxWidth) {
|
||||
Widget _buildPage(ThemeData theme) {
|
||||
double padding = max(maxWidth / 2 - Grid.smallCardWidth, 0);
|
||||
if (isPortrait) {
|
||||
return Padding(
|
||||
@@ -462,12 +459,12 @@ class _ArticlePageState extends CommonDynPageState<ArticlePage> {
|
||||
: HttpError(onReload: controller.onReload),
|
||||
Error(:var errMsg) => HttpError(
|
||||
errMsg: errMsg,
|
||||
onReload: controller.onReload,
|
||||
onReload: controller.isLoaded.value ? controller.onReload : null,
|
||||
),
|
||||
};
|
||||
}
|
||||
|
||||
PreferredSizeWidget _buildAppBar(bool isPortrait, double maxWidth) => AppBar(
|
||||
PreferredSizeWidget _buildAppBar() => AppBar(
|
||||
title: Obx(() {
|
||||
if (controller.isLoaded.value && controller.showTitle.value) {
|
||||
return Text(controller.summary.title ?? '');
|
||||
|
||||
@@ -62,7 +62,6 @@ class OpusContent extends StatelessWidget {
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
// if (kDebugMode) debugPrint('opusContent');
|
||||
|
||||
if (opus.isEmpty) {
|
||||
return const SliverToBoxAdapter();
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user