mirror of
https://github.com/bggRGjQaUbCoE/PiliPlus.git
synced 2026-05-31 16:18:22 +08:00
show dyn interaction
Signed-off-by: bggRGjQaUbCoE <githubaccount56556@proton.me>
This commit is contained in:
@@ -167,6 +167,7 @@ class ItemModulesModel {
|
|||||||
List<ArticleContentModel>? moduleContent;
|
List<ArticleContentModel>? moduleContent;
|
||||||
ModuleBlocked? moduleBlocked;
|
ModuleBlocked? moduleBlocked;
|
||||||
ModuleFold? moduleFold;
|
ModuleFold? moduleFold;
|
||||||
|
ModuleInteraction? moduleInteraction;
|
||||||
|
|
||||||
ItemModulesModel.fromJson(Map<String, dynamic> json) {
|
ItemModulesModel.fromJson(Map<String, dynamic> json) {
|
||||||
moduleAuthor = json['module_author'] != null
|
moduleAuthor = json['module_author'] != null
|
||||||
@@ -184,6 +185,9 @@ class ItemModulesModel {
|
|||||||
moduleFold = json['module_fold'] != null
|
moduleFold = json['module_fold'] != null
|
||||||
? ModuleFold.fromJson(json['module_fold'])
|
? ModuleFold.fromJson(json['module_fold'])
|
||||||
: null;
|
: null;
|
||||||
|
moduleInteraction = json['module_interaction'] != null
|
||||||
|
? ModuleInteraction.fromJson(json['module_interaction'])
|
||||||
|
: null;
|
||||||
}
|
}
|
||||||
|
|
||||||
ItemModulesModel.fromOpusJson(List json) {
|
ItemModulesModel.fromOpusJson(List json) {
|
||||||
@@ -234,6 +238,28 @@ class ItemModulesModel {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
class ModuleInteraction {
|
||||||
|
List<ModuleInteractionItem>? items;
|
||||||
|
|
||||||
|
ModuleInteraction.fromJson(Map<String, dynamic> json) {
|
||||||
|
items = (json['items'] as List?)
|
||||||
|
?.map((e) => ModuleInteractionItem.fromJson(e))
|
||||||
|
.toList();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
class ModuleInteractionItem {
|
||||||
|
int? type;
|
||||||
|
DynamicDescModel? desc;
|
||||||
|
|
||||||
|
ModuleInteractionItem.fromJson(Map<String, dynamic> json) {
|
||||||
|
type = json['type'];
|
||||||
|
desc = json["desc"] == null
|
||||||
|
? null
|
||||||
|
: DynamicDescModel.fromJson(json["desc"]);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
class ModuleFold {
|
class ModuleFold {
|
||||||
List<String>? ids;
|
List<String>? ids;
|
||||||
String? statement;
|
String? statement;
|
||||||
|
|||||||
@@ -5,6 +5,7 @@ import 'package:PiliPlus/models/dynamics/result.dart';
|
|||||||
import 'package:PiliPlus/pages/dynamics/widgets/action_panel.dart';
|
import 'package:PiliPlus/pages/dynamics/widgets/action_panel.dart';
|
||||||
import 'package:PiliPlus/pages/dynamics/widgets/author_panel.dart';
|
import 'package:PiliPlus/pages/dynamics/widgets/author_panel.dart';
|
||||||
import 'package:PiliPlus/pages/dynamics/widgets/dyn_content.dart';
|
import 'package:PiliPlus/pages/dynamics/widgets/dyn_content.dart';
|
||||||
|
import 'package:PiliPlus/pages/dynamics/widgets/interaction.dart';
|
||||||
import 'package:PiliPlus/utils/page_utils.dart';
|
import 'package:PiliPlus/utils/page_utils.dart';
|
||||||
import 'package:PiliPlus/utils/platform_utils.dart';
|
import 'package:PiliPlus/utils/platform_utils.dart';
|
||||||
import 'package:flutter/material.dart' hide InkWell;
|
import 'package:flutter/material.dart' hide InkWell;
|
||||||
@@ -88,6 +89,12 @@ class DynamicPanel extends StatelessWidget {
|
|||||||
),
|
),
|
||||||
const SizedBox(height: 2),
|
const SizedBox(height: 2),
|
||||||
if (!isDetail) ...[
|
if (!isDetail) ...[
|
||||||
|
if (item.modules.moduleInteraction case final moduleInteraction?)
|
||||||
|
if (moduleInteraction.items?.isNotEmpty == true)
|
||||||
|
dynInteraction(
|
||||||
|
theme: theme,
|
||||||
|
items: moduleInteraction.items!,
|
||||||
|
),
|
||||||
ActionPanel(item: item),
|
ActionPanel(item: item),
|
||||||
if (item.modules.moduleFold case final moduleFold?) ...[
|
if (item.modules.moduleFold case final moduleFold?) ...[
|
||||||
Divider(
|
Divider(
|
||||||
|
|||||||
90
lib/pages/dynamics/widgets/interaction.dart
Normal file
90
lib/pages/dynamics/widgets/interaction.dart
Normal file
@@ -0,0 +1,90 @@
|
|||||||
|
import 'package:PiliPlus/models/dynamics/result.dart';
|
||||||
|
import 'package:flutter/foundation.dart' show kDebugMode;
|
||||||
|
import 'package:flutter/gestures.dart';
|
||||||
|
import 'package:flutter/material.dart';
|
||||||
|
import 'package:font_awesome_flutter/font_awesome_flutter.dart';
|
||||||
|
import 'package:get/get_core/src/get_main.dart';
|
||||||
|
import 'package:get/get_navigation/src/extension_navigation.dart';
|
||||||
|
|
||||||
|
Widget dynInteraction({
|
||||||
|
required ThemeData theme,
|
||||||
|
required List<ModuleInteractionItem> items,
|
||||||
|
}) {
|
||||||
|
try {
|
||||||
|
Widget child;
|
||||||
|
if (items.length > 1) {
|
||||||
|
child = Column(
|
||||||
|
spacing: 3,
|
||||||
|
mainAxisSize: .min,
|
||||||
|
crossAxisAlignment: .start,
|
||||||
|
children: items.map((e) => _item(theme, e)).toList(),
|
||||||
|
);
|
||||||
|
} else {
|
||||||
|
child = _item(theme, items.single);
|
||||||
|
}
|
||||||
|
return Container(
|
||||||
|
padding: const .only(left: 8),
|
||||||
|
margin: const .only(left: 12, right: 12, top: 6),
|
||||||
|
decoration: BoxDecoration(
|
||||||
|
border: Border(
|
||||||
|
left: BorderSide(
|
||||||
|
width: 1.5,
|
||||||
|
color: theme.colorScheme.outline.withValues(alpha: 0.3),
|
||||||
|
),
|
||||||
|
),
|
||||||
|
),
|
||||||
|
child: child,
|
||||||
|
);
|
||||||
|
} catch (e) {
|
||||||
|
if (kDebugMode) {
|
||||||
|
return Text(
|
||||||
|
'interaction error: $e',
|
||||||
|
style: TextStyle(color: theme.colorScheme.error),
|
||||||
|
);
|
||||||
|
}
|
||||||
|
return const SizedBox.shrink();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
Widget _item(
|
||||||
|
ThemeData theme,
|
||||||
|
ModuleInteractionItem item,
|
||||||
|
) {
|
||||||
|
return Text.rich(
|
||||||
|
style: const TextStyle(fontSize: 13, height: 1.3),
|
||||||
|
strutStyle: const StrutStyle(fontSize: 13, height: 1.3, leading: 0),
|
||||||
|
TextSpan(
|
||||||
|
children: [
|
||||||
|
WidgetSpan(
|
||||||
|
alignment: .middle,
|
||||||
|
child: Padding(
|
||||||
|
padding: const .only(right: 6),
|
||||||
|
child: Icon(
|
||||||
|
size: 13,
|
||||||
|
color: theme.colorScheme.outline,
|
||||||
|
switch (item.type) {
|
||||||
|
1 => FontAwesomeIcons.comment,
|
||||||
|
_ => FontAwesomeIcons.thumbsUp,
|
||||||
|
},
|
||||||
|
),
|
||||||
|
),
|
||||||
|
),
|
||||||
|
...item.desc!.richTextNodes!.map(
|
||||||
|
(e) {
|
||||||
|
final isAt = e.type == 'RICH_TEXT_NODE_TYPE_AT';
|
||||||
|
return TextSpan(
|
||||||
|
text: e.origText,
|
||||||
|
style: isAt
|
||||||
|
? null
|
||||||
|
: TextStyle(color: theme.colorScheme.onSurfaceVariant),
|
||||||
|
recognizer: isAt
|
||||||
|
? (TapGestureRecognizer()
|
||||||
|
..onTap = () => Get.toNamed('/member?mid=${e.rid}'))
|
||||||
|
: null,
|
||||||
|
);
|
||||||
|
},
|
||||||
|
),
|
||||||
|
],
|
||||||
|
),
|
||||||
|
);
|
||||||
|
}
|
||||||
Reference in New Issue
Block a user