Browse Source

增加缓存

weicu
tanlongsheng 1 year ago
parent
commit
b53010e18a
  1. 40
      lib/modules/meeting/views/meeting_home_view.dart
  2. 51
      lib/modules/meeting/views/meeting_mine_view.dart

40
lib/modules/meeting/views/meeting_home_view.dart

@ -11,15 +11,27 @@ import '../model/meeting_model.dart';
import 'bottomSheet/edit_title_bottom_sheet.dart';
import 'bottomSheet/import_audio_bottom_sheet.dart';
class MeetingHomeView extends GetView<MeetingHomeController> {
class MeetingHomeView extends StatefulWidget {
const MeetingHomeView({super.key});
@override
State<MeetingHomeView> createState() => _MeetingHomeViewState();
}
class _MeetingHomeViewState extends State<MeetingHomeView>
with AutomaticKeepAliveClientMixin {
final _controller = Get.put(MeetingHomeController());
@override
bool get wantKeepAlive => true;
@override
Widget build(BuildContext context) {
super.build(context);
final isDarkMode = Theme.of(context).brightness == Brightness.dark;
return PopScope(
onPopInvokedWithResult: controller.onPopInvokedWithResult,
onPopInvokedWithResult: _controller.onPopInvokedWithResult,
child: Scaffold(
backgroundColor: isDarkMode ? Colors.black : Colors.grey[100],
appBar: _buildAppBar(isDarkMode),
@ -61,7 +73,7 @@ class MeetingHomeView extends GetView<MeetingHomeController> {
Widget _buildFiltrate(bool isDarkMode) {
return GestureDetector(
onTap: () {
controller.meetingController.scaffoldKey.currentState?.openDrawer();
_controller.meetingController.scaffoldKey.currentState?.openDrawer();
},
behavior: HitTestBehavior.translucent,
child: Row(
@ -95,7 +107,7 @@ class MeetingHomeView extends GetView<MeetingHomeController> {
5.horizontalSpace,
Obx(
() => Text(
'${controller.filtrateType.value.isNotEmpty ? controller.filtrateType : '全部文件'}(${controller.dataList.length})',
'${_controller.filtrateType.value.isNotEmpty ? _controller.filtrateType : '全部文件'}(${_controller.dataList.length})',
style: TextStyle(
color: isDarkMode ? Colors.white : Colors.black87,
fontSize: 16.sp,
@ -194,10 +206,11 @@ class MeetingHomeView extends GetView<MeetingHomeController> {
Widget _buildBody(BuildContext context, bool isDarkMode) {
return Obx(
() => ListView.builder(
itemCount: controller.dataList.length,
itemCount: _controller.dataList.length,
padding: EdgeInsets.fromLTRB(12.w, 5.w, 12.w, 90.w),
itemBuilder: (BuildContext context, int index) {
MeetingModel data = MeetingModel.fromJson(controller.dataList[index]);
MeetingModel data =
MeetingModel.fromJson(_controller.dataList[index]);
return _item(context, isDarkMode, data);
},
),
@ -298,7 +311,7 @@ class MeetingHomeView extends GetView<MeetingHomeController> {
const Spacer(),
Obx(() {
Map uploadData =
controller.meetingUploadService.uploadList.firstWhere(
_controller.meetingUploadService.uploadList.firstWhere(
(element) => element['id'] == data.id,
orElse: () => {},
);
@ -307,13 +320,14 @@ class MeetingHomeView extends GetView<MeetingHomeController> {
alignment: Alignment.center,
children: [
if (uploadData['id'] ==
controller.meetingUploadService.meetingId.value)
_controller
.meetingUploadService.meetingId.value)
Obx(
() => SizedBox(
width: 20.w,
height: 20.w,
child: CircularProgressIndicator(
value: controller.meetingUploadService
value: _controller.meetingUploadService
.uploadProgress.value,
valueColor:
const AlwaysStoppedAnimation<Color>(
@ -339,7 +353,7 @@ class MeetingHomeView extends GetView<MeetingHomeController> {
}),
Obx(() {
Map taskData =
controller.meetingTaskService.taskFinishList.firstWhere(
_controller.meetingTaskService.taskFinishList.firstWhere(
(element) => element['id'] == data.id,
orElse: () => {},
);
@ -401,9 +415,9 @@ class MeetingHomeView extends GetView<MeetingHomeController> {
isDarkMode ? Colors.white : Colors.black87,
() {
final dotIndex = data.title.lastIndexOf('.');
controller.titleController.text =
_controller.titleController.text =
dotIndex != -1 ? data.title.substring(0, dotIndex) : data.title;
controller.titleCSuffix =
_controller.titleCSuffix =
data.title.substring(dotIndex, data.title.length);
Get.bottomSheet(
EditTitleBottomSheet(data.id),
@ -426,7 +440,7 @@ class MeetingHomeView extends GetView<MeetingHomeController> {
'delete'.tr, // 删除
isDarkMode ? Colors.red[700]! : Colors.red,
() {
controller.deleteMeeting(data.id, data.filepath);
_controller.deleteMeeting(data.id, data.filepath);
},
),
],

51
lib/modules/meeting/views/meeting_mine_view.dart

@ -7,11 +7,23 @@ import '../../../routes/app_routes.dart';
import '../controllers/meeting_mine_controller.dart';
import 'bottomSheet/statistics_bottom_sheet.dart';
class MeetingMineView extends GetView<MeetingMineController> {
class MeetingMineView extends StatefulWidget {
const MeetingMineView({super.key});
@override
State<MeetingMineView> createState() => _MeetingMineViewState();
}
class _MeetingMineViewState extends State<MeetingMineView>
with AutomaticKeepAliveClientMixin {
final _controller = Get.put(MeetingMineController());
@override
bool get wantKeepAlive => true;
@override
Widget build(BuildContext context) {
super.build(context);
return Scaffold(
backgroundColor: Colors.grey[100],
body: Container(
@ -112,17 +124,18 @@ class MeetingMineView extends GetView<MeetingMineController> {
),
child: CircleAvatar(
radius: 25.w,
backgroundImage: controller
.profileCtrl.localAvatar.value.isNotEmpty
? FileImage(
File(controller.profileCtrl.localAvatar.value))
: (controller.profileCtrl.userInfo.value.avatar.isNotEmpty
? NetworkImage(
controller.profileCtrl.userInfo.value.avatar)
: null) as ImageProvider<Object>?,
backgroundImage:
_controller.profileCtrl.localAvatar.value.isNotEmpty
? FileImage(
File(_controller.profileCtrl.localAvatar.value))
: (_controller
.profileCtrl.userInfo.value.avatar.isNotEmpty
? NetworkImage(
_controller.profileCtrl.userInfo.value.avatar)
: null) as ImageProvider<Object>?,
backgroundColor: Colors.grey[200],
child: (controller.profileCtrl.localAvatar.value.isEmpty &&
controller.profileCtrl.userInfo.value.avatar.isEmpty)
child: (_controller.profileCtrl.localAvatar.value.isEmpty &&
_controller.profileCtrl.userInfo.value.avatar.isEmpty)
? Icon(
Icons.person,
size: 25.r,
@ -135,7 +148,7 @@ class MeetingMineView extends GetView<MeetingMineController> {
Expanded(
child: Obx(
() => Text(
controller.profileCtrl.userInfo.value.name,
_controller.profileCtrl.userInfo.value.name,
style: TextStyle(
color: Colors.black87,
fontSize: 20.sp,
@ -176,17 +189,17 @@ class MeetingMineView extends GetView<MeetingMineController> {
Row(
children: [
_statisticsItem(
'${controller.days.value}',
'${_controller.days.value}',
'天',
Colors.lime,
),
_statisticsItem(
'${controller.numberFiles.value}',
'${_controller.numberFiles.value}',
'文件',
Colors.lightGreen,
),
_statisticsItem(
'${controller.hourage.value}',
'${_controller.hourage.value}',
'小时',
Colors.blueGrey,
),
@ -197,7 +210,7 @@ class MeetingMineView extends GetView<MeetingMineController> {
padding: EdgeInsets.symmetric(horizontal: 2.w),
margin: EdgeInsets.only(top: 8.w, bottom: 2.w),
child: GridView.builder(
controller: controller.scrollController,
controller: _controller.scrollController,
scrollDirection: Axis.horizontal,
gridDelegate: SliverGridDelegateWithFixedCrossAxisCount(
crossAxisCount: 7,
@ -207,9 +220,9 @@ class MeetingMineView extends GetView<MeetingMineController> {
itemCount: 364,
itemBuilder: (BuildContext context, int index) {
int type = 0;
if (controller.statistics.containsKey(index + 1)) {
if (controller.statistics[index + 1]['count'] <=
controller.averageNumberFiles) {
if (_controller.statistics.containsKey(index + 1)) {
if (_controller.statistics[index + 1]['count'] <=
_controller.averageNumberFiles) {
type = 1;
} else {
type = 2;

Loading…
Cancel
Save