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/edit_title_bottom_sheet.dart';
import 'bottomSheet/import_audio_bottom_sheet.dart'; import 'bottomSheet/import_audio_bottom_sheet.dart';
class MeetingHomeView extends GetView<MeetingHomeController> { class MeetingHomeView extends StatefulWidget {
const MeetingHomeView({super.key}); 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 @override
Widget build(BuildContext context) { Widget build(BuildContext context) {
super.build(context);
final isDarkMode = Theme.of(context).brightness == Brightness.dark; final isDarkMode = Theme.of(context).brightness == Brightness.dark;
return PopScope( return PopScope(
onPopInvokedWithResult: controller.onPopInvokedWithResult, onPopInvokedWithResult: _controller.onPopInvokedWithResult,
child: Scaffold( child: Scaffold(
backgroundColor: isDarkMode ? Colors.black : Colors.grey[100], backgroundColor: isDarkMode ? Colors.black : Colors.grey[100],
appBar: _buildAppBar(isDarkMode), appBar: _buildAppBar(isDarkMode),
@ -61,7 +73,7 @@ class MeetingHomeView extends GetView<MeetingHomeController> {
Widget _buildFiltrate(bool isDarkMode) { Widget _buildFiltrate(bool isDarkMode) {
return GestureDetector( return GestureDetector(
onTap: () { onTap: () {
controller.meetingController.scaffoldKey.currentState?.openDrawer(); _controller.meetingController.scaffoldKey.currentState?.openDrawer();
}, },
behavior: HitTestBehavior.translucent, behavior: HitTestBehavior.translucent,
child: Row( child: Row(
@ -95,7 +107,7 @@ class MeetingHomeView extends GetView<MeetingHomeController> {
5.horizontalSpace, 5.horizontalSpace,
Obx( Obx(
() => Text( () => Text(
'${controller.filtrateType.value.isNotEmpty ? controller.filtrateType : '全部文件'}(${controller.dataList.length})', '${_controller.filtrateType.value.isNotEmpty ? _controller.filtrateType : '全部文件'}(${_controller.dataList.length})',
style: TextStyle( style: TextStyle(
color: isDarkMode ? Colors.white : Colors.black87, color: isDarkMode ? Colors.white : Colors.black87,
fontSize: 16.sp, fontSize: 16.sp,
@ -194,10 +206,11 @@ class MeetingHomeView extends GetView<MeetingHomeController> {
Widget _buildBody(BuildContext context, bool isDarkMode) { Widget _buildBody(BuildContext context, bool isDarkMode) {
return Obx( return Obx(
() => ListView.builder( () => ListView.builder(
itemCount: controller.dataList.length, itemCount: _controller.dataList.length,
padding: EdgeInsets.fromLTRB(12.w, 5.w, 12.w, 90.w), padding: EdgeInsets.fromLTRB(12.w, 5.w, 12.w, 90.w),
itemBuilder: (BuildContext context, int index) { itemBuilder: (BuildContext context, int index) {
MeetingModel data = MeetingModel.fromJson(controller.dataList[index]); MeetingModel data =
MeetingModel.fromJson(_controller.dataList[index]);
return _item(context, isDarkMode, data); return _item(context, isDarkMode, data);
}, },
), ),
@ -298,7 +311,7 @@ class MeetingHomeView extends GetView<MeetingHomeController> {
const Spacer(), const Spacer(),
Obx(() { Obx(() {
Map uploadData = Map uploadData =
controller.meetingUploadService.uploadList.firstWhere( _controller.meetingUploadService.uploadList.firstWhere(
(element) => element['id'] == data.id, (element) => element['id'] == data.id,
orElse: () => {}, orElse: () => {},
); );
@ -307,13 +320,14 @@ class MeetingHomeView extends GetView<MeetingHomeController> {
alignment: Alignment.center, alignment: Alignment.center,
children: [ children: [
if (uploadData['id'] == if (uploadData['id'] ==
controller.meetingUploadService.meetingId.value) _controller
.meetingUploadService.meetingId.value)
Obx( Obx(
() => SizedBox( () => SizedBox(
width: 20.w, width: 20.w,
height: 20.w, height: 20.w,
child: CircularProgressIndicator( child: CircularProgressIndicator(
value: controller.meetingUploadService value: _controller.meetingUploadService
.uploadProgress.value, .uploadProgress.value,
valueColor: valueColor:
const AlwaysStoppedAnimation<Color>( const AlwaysStoppedAnimation<Color>(
@ -339,7 +353,7 @@ class MeetingHomeView extends GetView<MeetingHomeController> {
}), }),
Obx(() { Obx(() {
Map taskData = Map taskData =
controller.meetingTaskService.taskFinishList.firstWhere( _controller.meetingTaskService.taskFinishList.firstWhere(
(element) => element['id'] == data.id, (element) => element['id'] == data.id,
orElse: () => {}, orElse: () => {},
); );
@ -401,9 +415,9 @@ class MeetingHomeView extends GetView<MeetingHomeController> {
isDarkMode ? Colors.white : Colors.black87, isDarkMode ? Colors.white : Colors.black87,
() { () {
final dotIndex = data.title.lastIndexOf('.'); final dotIndex = data.title.lastIndexOf('.');
controller.titleController.text = _controller.titleController.text =
dotIndex != -1 ? data.title.substring(0, dotIndex) : data.title; dotIndex != -1 ? data.title.substring(0, dotIndex) : data.title;
controller.titleCSuffix = _controller.titleCSuffix =
data.title.substring(dotIndex, data.title.length); data.title.substring(dotIndex, data.title.length);
Get.bottomSheet( Get.bottomSheet(
EditTitleBottomSheet(data.id), EditTitleBottomSheet(data.id),
@ -426,7 +440,7 @@ class MeetingHomeView extends GetView<MeetingHomeController> {
'delete'.tr, // 删除 'delete'.tr, // 删除
isDarkMode ? Colors.red[700]! : Colors.red, 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 '../controllers/meeting_mine_controller.dart';
import 'bottomSheet/statistics_bottom_sheet.dart'; import 'bottomSheet/statistics_bottom_sheet.dart';
class MeetingMineView extends GetView<MeetingMineController> { class MeetingMineView extends StatefulWidget {
const MeetingMineView({super.key}); 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 @override
Widget build(BuildContext context) { Widget build(BuildContext context) {
super.build(context);
return Scaffold( return Scaffold(
backgroundColor: Colors.grey[100], backgroundColor: Colors.grey[100],
body: Container( body: Container(
@ -112,17 +124,18 @@ class MeetingMineView extends GetView<MeetingMineController> {
), ),
child: CircleAvatar( child: CircleAvatar(
radius: 25.w, radius: 25.w,
backgroundImage: controller backgroundImage:
.profileCtrl.localAvatar.value.isNotEmpty _controller.profileCtrl.localAvatar.value.isNotEmpty
? FileImage( ? FileImage(
File(controller.profileCtrl.localAvatar.value)) File(_controller.profileCtrl.localAvatar.value))
: (controller.profileCtrl.userInfo.value.avatar.isNotEmpty : (_controller
? NetworkImage( .profileCtrl.userInfo.value.avatar.isNotEmpty
controller.profileCtrl.userInfo.value.avatar) ? NetworkImage(
: null) as ImageProvider<Object>?, _controller.profileCtrl.userInfo.value.avatar)
: null) as ImageProvider<Object>?,
backgroundColor: Colors.grey[200], backgroundColor: Colors.grey[200],
child: (controller.profileCtrl.localAvatar.value.isEmpty && child: (_controller.profileCtrl.localAvatar.value.isEmpty &&
controller.profileCtrl.userInfo.value.avatar.isEmpty) _controller.profileCtrl.userInfo.value.avatar.isEmpty)
? Icon( ? Icon(
Icons.person, Icons.person,
size: 25.r, size: 25.r,
@ -135,7 +148,7 @@ class MeetingMineView extends GetView<MeetingMineController> {
Expanded( Expanded(
child: Obx( child: Obx(
() => Text( () => Text(
controller.profileCtrl.userInfo.value.name, _controller.profileCtrl.userInfo.value.name,
style: TextStyle( style: TextStyle(
color: Colors.black87, color: Colors.black87,
fontSize: 20.sp, fontSize: 20.sp,
@ -176,17 +189,17 @@ class MeetingMineView extends GetView<MeetingMineController> {
Row( Row(
children: [ children: [
_statisticsItem( _statisticsItem(
'${controller.days.value}', '${_controller.days.value}',
'天', '天',
Colors.lime, Colors.lime,
), ),
_statisticsItem( _statisticsItem(
'${controller.numberFiles.value}', '${_controller.numberFiles.value}',
'文件', '文件',
Colors.lightGreen, Colors.lightGreen,
), ),
_statisticsItem( _statisticsItem(
'${controller.hourage.value}', '${_controller.hourage.value}',
'小时', '小时',
Colors.blueGrey, Colors.blueGrey,
), ),
@ -197,7 +210,7 @@ class MeetingMineView extends GetView<MeetingMineController> {
padding: EdgeInsets.symmetric(horizontal: 2.w), padding: EdgeInsets.symmetric(horizontal: 2.w),
margin: EdgeInsets.only(top: 8.w, bottom: 2.w), margin: EdgeInsets.only(top: 8.w, bottom: 2.w),
child: GridView.builder( child: GridView.builder(
controller: controller.scrollController, controller: _controller.scrollController,
scrollDirection: Axis.horizontal, scrollDirection: Axis.horizontal,
gridDelegate: SliverGridDelegateWithFixedCrossAxisCount( gridDelegate: SliverGridDelegateWithFixedCrossAxisCount(
crossAxisCount: 7, crossAxisCount: 7,
@ -207,9 +220,9 @@ class MeetingMineView extends GetView<MeetingMineController> {
itemCount: 364, itemCount: 364,
itemBuilder: (BuildContext context, int index) { itemBuilder: (BuildContext context, int index) {
int type = 0; int type = 0;
if (controller.statistics.containsKey(index + 1)) { if (_controller.statistics.containsKey(index + 1)) {
if (controller.statistics[index + 1]['count'] <= if (_controller.statistics[index + 1]['count'] <=
controller.averageNumberFiles) { _controller.averageNumberFiles) {
type = 1; type = 1;
} else { } else {
type = 2; type = 2;

Loading…
Cancel
Save