mod: 动态页面
This commit is contained in:
@ -17,7 +17,8 @@ class DynamicsController extends GetxController {
|
|||||||
final ScrollController scrollController = ScrollController();
|
final ScrollController scrollController = ScrollController();
|
||||||
Rx<FollowUpModel> upData = FollowUpModel().obs;
|
Rx<FollowUpModel> upData = FollowUpModel().obs;
|
||||||
// 默认获取全部动态
|
// 默认获取全部动态
|
||||||
int mid = -1;
|
RxInt mid = (-1).obs;
|
||||||
|
Rx<UpItem> upInfo = UpItem().obs;
|
||||||
List filterTypeList = [
|
List filterTypeList = [
|
||||||
{
|
{
|
||||||
'label': DynamicsType.all.labels,
|
'label': DynamicsType.all.labels,
|
||||||
@ -41,6 +42,7 @@ class DynamicsController extends GetxController {
|
|||||||
},
|
},
|
||||||
];
|
];
|
||||||
bool flag = false;
|
bool flag = false;
|
||||||
|
RxInt initialValue = 1.obs;
|
||||||
|
|
||||||
Future queryFollowDynamic({type = 'init'}) async {
|
Future queryFollowDynamic({type = 'init'}) async {
|
||||||
// if (type == 'init') {
|
// if (type == 'init') {
|
||||||
@ -50,7 +52,7 @@ class DynamicsController extends GetxController {
|
|||||||
page: type == 'init' ? 1 : page,
|
page: type == 'init' ? 1 : page,
|
||||||
type: dynamicsType.value.values,
|
type: dynamicsType.value.values,
|
||||||
offset: offset,
|
offset: offset,
|
||||||
mid: mid,
|
mid: mid.value,
|
||||||
);
|
);
|
||||||
if (res['status']) {
|
if (res['status']) {
|
||||||
if (type == 'init') {
|
if (type == 'init') {
|
||||||
@ -65,7 +67,10 @@ class DynamicsController extends GetxController {
|
|||||||
}
|
}
|
||||||
|
|
||||||
onSelectType(value) async {
|
onSelectType(value) async {
|
||||||
dynamicsType.value = value;
|
dynamicsType.value = filterTypeList[value - 1]['value'];
|
||||||
|
dynamicsList!.value = [DynamicItemModel()];
|
||||||
|
page = 1;
|
||||||
|
initialValue.value = value;
|
||||||
await queryFollowDynamic();
|
await queryFollowDynamic();
|
||||||
scrollController.jumpTo(0);
|
scrollController.jumpTo(0);
|
||||||
}
|
}
|
||||||
@ -127,7 +132,8 @@ class DynamicsController extends GetxController {
|
|||||||
|
|
||||||
onSelectUp(mid) async {
|
onSelectUp(mid) async {
|
||||||
dynamicsType.value = DynamicsType.values[0];
|
dynamicsType.value = DynamicsType.values[0];
|
||||||
|
dynamicsList!.value = [DynamicItemModel()];
|
||||||
|
page = 1;
|
||||||
queryFollowDynamic();
|
queryFollowDynamic();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1,3 +1,5 @@
|
|||||||
|
import 'package:custom_sliding_segmented_control/custom_sliding_segmented_control.dart';
|
||||||
|
import 'package:flutter/cupertino.dart';
|
||||||
import 'package:flutter/material.dart';
|
import 'package:flutter/material.dart';
|
||||||
import 'package:flutter_smart_dialog/flutter_smart_dialog.dart';
|
import 'package:flutter_smart_dialog/flutter_smart_dialog.dart';
|
||||||
import 'package:get/get.dart';
|
import 'package:get/get.dart';
|
||||||
@ -59,40 +61,94 @@ class _DynamicsPageState extends State<DynamicsPage>
|
|||||||
Row(
|
Row(
|
||||||
mainAxisAlignment: MainAxisAlignment.center,
|
mainAxisAlignment: MainAxisAlignment.center,
|
||||||
children: [
|
children: [
|
||||||
Obx(
|
Obx(() {
|
||||||
() => SegmentedButton<DynamicsType>(
|
if (_dynamicsController.mid.value != -1 &&
|
||||||
showSelectedIcon: false,
|
_dynamicsController.upInfo.value.uname != null) {
|
||||||
style: ButtonStyle(
|
return SizedBox(
|
||||||
padding: MaterialStateProperty.all(
|
height: 36,
|
||||||
const EdgeInsets.symmetric(
|
child: AnimatedSwitcher(
|
||||||
vertical: 0, horizontal: 10)),
|
duration: const Duration(milliseconds: 300),
|
||||||
side: MaterialStateProperty.all(
|
transitionBuilder:
|
||||||
BorderSide(
|
(Widget child, Animation<double> animation) {
|
||||||
color: Theme.of(context).hintColor, width: 0.5),
|
return ScaleTransition(
|
||||||
|
scale: animation, child: child);
|
||||||
|
},
|
||||||
|
child: Text(
|
||||||
|
'${_dynamicsController.upInfo.value.uname!}的动态',
|
||||||
|
key: ValueKey<String>(
|
||||||
|
_dynamicsController.upInfo.value.uname!),
|
||||||
|
style: TextStyle(
|
||||||
|
fontSize: Theme.of(context)
|
||||||
|
.textTheme
|
||||||
|
.labelLarge!
|
||||||
|
.fontSize,
|
||||||
|
)),
|
||||||
),
|
),
|
||||||
),
|
);
|
||||||
segments: <ButtonSegment<DynamicsType>>[
|
} else {
|
||||||
for (var i in _dynamicsController.filterTypeList) ...[
|
return const SizedBox();
|
||||||
ButtonSegment<DynamicsType>(
|
}
|
||||||
value: i['value'],
|
}),
|
||||||
label: Padding(
|
Obx(() => Visibility(
|
||||||
padding: const EdgeInsets.only(bottom: 10),
|
visible: _dynamicsController.mid.value == -1,
|
||||||
child: Text(i['label']),
|
child: CustomSlidingSegmentedControl<int>(
|
||||||
|
initialValue: _dynamicsController.initialValue.value,
|
||||||
|
children: {
|
||||||
|
1: Text(
|
||||||
|
'全部',
|
||||||
|
style: TextStyle(
|
||||||
|
fontSize: Theme.of(context)
|
||||||
|
.textTheme
|
||||||
|
.labelMedium!
|
||||||
|
.fontSize),
|
||||||
),
|
),
|
||||||
enabled: i['enabled'],
|
2: Text('投稿',
|
||||||
|
style: TextStyle(
|
||||||
|
fontSize: Theme.of(context)
|
||||||
|
.textTheme
|
||||||
|
.labelMedium!
|
||||||
|
.fontSize)),
|
||||||
|
3: Text('番剧',
|
||||||
|
style: TextStyle(
|
||||||
|
fontSize: Theme.of(context)
|
||||||
|
.textTheme
|
||||||
|
.labelMedium!
|
||||||
|
.fontSize)),
|
||||||
|
// 4: Text(
|
||||||
|
// '专栏',
|
||||||
|
// style: TextStyle(
|
||||||
|
// fontSize: Theme.of(context)
|
||||||
|
// .textTheme
|
||||||
|
// .labelMedium!
|
||||||
|
// .fontSize),
|
||||||
|
// ),
|
||||||
|
},
|
||||||
|
padding: 16.0,
|
||||||
|
decoration: BoxDecoration(
|
||||||
|
color: Theme.of(context)
|
||||||
|
.colorScheme
|
||||||
|
.surfaceVariant
|
||||||
|
.withOpacity(0.7),
|
||||||
|
borderRadius: BorderRadius.circular(20),
|
||||||
),
|
),
|
||||||
]
|
thumbDecoration: BoxDecoration(
|
||||||
],
|
color: Theme.of(context).colorScheme.background,
|
||||||
selected: <DynamicsType>{
|
borderRadius: BorderRadius.circular(20),
|
||||||
_dynamicsController.dynamicsType.value
|
border: Border.all(
|
||||||
},
|
width: 1.2,
|
||||||
onSelectionChanged: (Set<DynamicsType> newSelection) {
|
color: Theme.of(context)
|
||||||
_dynamicsController.dynamicsType.value =
|
.colorScheme
|
||||||
newSelection.first;
|
.surfaceVariant
|
||||||
_dynamicsController.onSelectType(newSelection.first);
|
.withOpacity(0.7),
|
||||||
},
|
),
|
||||||
),
|
),
|
||||||
),
|
duration: const Duration(milliseconds: 300),
|
||||||
|
curve: Curves.easeInOut,
|
||||||
|
onValueChanged: (v) {
|
||||||
|
_dynamicsController.onSelectType(v);
|
||||||
|
},
|
||||||
|
),
|
||||||
|
))
|
||||||
],
|
],
|
||||||
),
|
),
|
||||||
Positioned(
|
Positioned(
|
||||||
@ -102,7 +158,7 @@ class _DynamicsPageState extends State<DynamicsPage>
|
|||||||
child: IconButton(
|
child: IconButton(
|
||||||
padding: EdgeInsets.zero,
|
padding: EdgeInsets.zero,
|
||||||
onPressed: () {
|
onPressed: () {
|
||||||
_dynamicsController.mid = -1;
|
_dynamicsController.mid.value = -1;
|
||||||
_dynamicsController.dynamicsType.value =
|
_dynamicsController.dynamicsType.value =
|
||||||
DynamicsType.values[0];
|
DynamicsType.values[0];
|
||||||
SmartDialog.showToast('还原默认加载',
|
SmartDialog.showToast('还原默认加载',
|
||||||
@ -150,11 +206,14 @@ class _DynamicsPageState extends State<DynamicsPage>
|
|||||||
List<DynamicItemModel> list =
|
List<DynamicItemModel> list =
|
||||||
_dynamicsController.dynamicsList!;
|
_dynamicsController.dynamicsList!;
|
||||||
return Obx(
|
return Obx(
|
||||||
() => SliverList(
|
() => list.length == 1
|
||||||
delegate: SliverChildBuilderDelegate((context, index) {
|
? skeleton()
|
||||||
return DynamicPanel(item: list[index]);
|
: SliverList(
|
||||||
}, childCount: list.length),
|
delegate:
|
||||||
),
|
SliverChildBuilderDelegate((context, index) {
|
||||||
|
return DynamicPanel(item: list[index]);
|
||||||
|
}, childCount: list.length),
|
||||||
|
),
|
||||||
);
|
);
|
||||||
} else {
|
} else {
|
||||||
return HttpError(
|
return HttpError(
|
||||||
|
@ -1,10 +1,7 @@
|
|||||||
import 'package:flutter/material.dart';
|
import 'package:flutter/material.dart';
|
||||||
import 'package:flutter_meedu_media_kit/meedu_player.dart';
|
|
||||||
import 'package:flutter_smart_dialog/flutter_smart_dialog.dart';
|
import 'package:flutter_smart_dialog/flutter_smart_dialog.dart';
|
||||||
import 'package:get/get.dart';
|
import 'package:get/get.dart';
|
||||||
import 'package:pilipala/common/widgets/badge.dart';
|
|
||||||
import 'package:pilipala/common/widgets/network_img_layer.dart';
|
import 'package:pilipala/common/widgets/network_img_layer.dart';
|
||||||
import 'package:pilipala/models/common/dynamics_type.dart';
|
|
||||||
import 'package:pilipala/models/dynamics/up.dart';
|
import 'package:pilipala/models/dynamics/up.dart';
|
||||||
import 'package:pilipala/pages/dynamics/controller.dart';
|
import 'package:pilipala/pages/dynamics/controller.dart';
|
||||||
|
|
||||||
@ -29,7 +26,12 @@ class _UpPanelState extends State<UpPanel> {
|
|||||||
super.initState();
|
super.initState();
|
||||||
upList = widget.upData!.upList!;
|
upList = widget.upData!.upList!;
|
||||||
liveList = widget.upData!.liveUsers!.items!;
|
liveList = widget.upData!.liveUsers!.items!;
|
||||||
upList.insert(0, UpItem(face: '', uname: '全部动态', mid: -1));
|
upList.insert(
|
||||||
|
0,
|
||||||
|
UpItem(
|
||||||
|
face: 'https://files.catbox.moe/8uc48f.png',
|
||||||
|
uname: '全部动态',
|
||||||
|
mid: -1));
|
||||||
}
|
}
|
||||||
|
|
||||||
@override
|
@override
|
||||||
@ -103,7 +105,8 @@ class _UpPanelState extends State<UpPanel> {
|
|||||||
onTap: () {
|
onTap: () {
|
||||||
if (data.type == 'up') {
|
if (data.type == 'up') {
|
||||||
currentMid = data.mid;
|
currentMid = data.mid;
|
||||||
Get.find<DynamicsController>().mid = data.mid;
|
Get.find<DynamicsController>().mid.value = data.mid;
|
||||||
|
Get.find<DynamicsController>().upInfo.value = data;
|
||||||
Get.find<DynamicsController>().onSelectUp(data.mid);
|
Get.find<DynamicsController>().onSelectUp(data.mid);
|
||||||
int liveLen = liveList.length;
|
int liveLen = liveList.length;
|
||||||
int upLen = upList.length;
|
int upLen = upList.length;
|
||||||
|
@ -225,6 +225,14 @@ packages:
|
|||||||
url: "https://pub.dev"
|
url: "https://pub.dev"
|
||||||
source: hosted
|
source: hosted
|
||||||
version: "1.0.5"
|
version: "1.0.5"
|
||||||
|
custom_sliding_segmented_control:
|
||||||
|
dependency: "direct main"
|
||||||
|
description:
|
||||||
|
name: custom_sliding_segmented_control
|
||||||
|
sha256: a12d1908bb3fe06aabd4becd7def608cdd77b01b7a9f79e37d9414b478523a34
|
||||||
|
url: "https://pub.dev"
|
||||||
|
source: hosted
|
||||||
|
version: "1.7.5"
|
||||||
dart_style:
|
dart_style:
|
||||||
dependency: transitive
|
dependency: transitive
|
||||||
description:
|
description:
|
||||||
|
@ -84,6 +84,7 @@ dependencies:
|
|||||||
url: https://github.com/guozhigq/flutter_meedu_media_kit.git
|
url: https://github.com/guozhigq/flutter_meedu_media_kit.git
|
||||||
ref: feature-custom
|
ref: feature-custom
|
||||||
path: package
|
path: package
|
||||||
|
custom_sliding_segmented_control: ^1.7.5
|
||||||
|
|
||||||
dev_dependencies:
|
dev_dependencies:
|
||||||
flutter_test:
|
flutter_test:
|
||||||
|
Reference in New Issue
Block a user