restore jobTable state mode

This commit is contained in:
csf 2023-03-09 00:06:24 +09:00
parent b7a0436aa3
commit a2f82b6ea6
2 changed files with 165 additions and 177 deletions

View File

@ -157,35 +157,7 @@ class _FileManagerPageState extends State<FileManagerPage>
/// transfer status list /// transfer status list
/// watch transfer status /// watch transfer status
Widget statusList() { Widget statusList() {
return PreferredSize( statusListView() => Obx(() => ListView.builder(
preferredSize: const Size(200, double.infinity),
child: Container(
margin: const EdgeInsets.only(top: 16.0, bottom: 16.0, right: 16.0),
padding: const EdgeInsets.all(8.0),
child: jobController.jobTable.isEmpty
? generateCard(
Center(
child: Column(
mainAxisAlignment: MainAxisAlignment.center,
children: [
SvgPicture.asset(
"assets/transfer.svg",
color: Theme.of(context).tabBarTheme.labelColor,
height: 40,
).paddingOnly(bottom: 10),
Text(
translate("No transfers in progress"),
textAlign: TextAlign.center,
textScaleFactor: 1.20,
style: TextStyle(
color: Theme.of(context).tabBarTheme.labelColor),
),
],
),
),
)
: Obx(
() => ListView.builder(
controller: ScrollController(), controller: ScrollController(),
itemBuilder: (BuildContext context, int index) { itemBuilder: (BuildContext context, int index) {
final item = jobController.jobTable[index]; final item = jobController.jobTable[index];
@ -202,9 +174,7 @@ class _FileManagerPageState extends State<FileManagerPage>
angle: item.isRemoteToLocal ? pi : 0, angle: item.isRemoteToLocal ? pi : 0,
child: SvgPicture.asset( child: SvgPicture.asset(
"assets/arrow.svg", "assets/arrow.svg",
color: Theme.of(context) color: Theme.of(context).tabBarTheme.labelColor,
.tabBarTheme
.labelColor,
), ),
).paddingOnly(left: 15), ).paddingOnly(left: 15),
const SizedBox( const SizedBox(
@ -213,12 +183,10 @@ class _FileManagerPageState extends State<FileManagerPage>
Expanded( Expanded(
child: Column( child: Column(
mainAxisSize: MainAxisSize.min, mainAxisSize: MainAxisSize.min,
crossAxisAlignment: crossAxisAlignment: CrossAxisAlignment.start,
CrossAxisAlignment.start,
children: [ children: [
Tooltip( Tooltip(
waitDuration: waitDuration: Duration(milliseconds: 500),
Duration(milliseconds: 500),
message: item.jobName, message: item.jobName,
child: Text( child: Text(
item.fileName, item.fileName,
@ -234,8 +202,7 @@ class _FileManagerPageState extends State<FileManagerPage>
), ),
), ),
Offstage( Offstage(
offstage: offstage: item.state != JobState.inProgress,
item.state != JobState.inProgress,
child: Text( child: Text(
'${translate("Speed")} ${readableFileSize(item.speed)}/s', '${translate("Speed")} ${readableFileSize(item.speed)}/s',
style: TextStyle( style: TextStyle(
@ -245,8 +212,7 @@ class _FileManagerPageState extends State<FileManagerPage>
), ),
), ),
Offstage( Offstage(
offstage: offstage: item.state == JobState.inProgress,
item.state == JobState.inProgress,
child: Text( child: Text(
translate( translate(
item.display(), item.display(),
@ -258,8 +224,7 @@ class _FileManagerPageState extends State<FileManagerPage>
), ),
), ),
Offstage( Offstage(
offstage: offstage: item.state != JobState.inProgress,
item.state != JobState.inProgress,
child: LinearPercentIndicator( child: LinearPercentIndicator(
padding: EdgeInsets.only(right: 15), padding: EdgeInsets.only(right: 15),
animateFromLastPercent: true, animateFromLastPercent: true,
@ -267,13 +232,10 @@ class _FileManagerPageState extends State<FileManagerPage>
'${(item.finishedSize / item.totalSize * 100).toStringAsFixed(0)}%', '${(item.finishedSize / item.totalSize * 100).toStringAsFixed(0)}%',
), ),
barRadius: Radius.circular(15), barRadius: Radius.circular(15),
percent: item.finishedSize / percent: item.finishedSize / item.totalSize,
item.totalSize,
progressColor: MyTheme.accent, progressColor: MyTheme.accent,
backgroundColor: backgroundColor: Theme.of(context).hoverColor,
Theme.of(context).hoverColor, lineHeight: kDesktopFileTransferRowHeight,
lineHeight:
kDesktopFileTransferRowHeight,
).paddingSymmetric(vertical: 15), ).paddingSymmetric(vertical: 15),
), ),
], ],
@ -319,9 +281,39 @@ class _FileManagerPageState extends State<FileManagerPage>
); );
}, },
itemCount: jobController.jobTable.length, itemCount: jobController.jobTable.length,
));
return PreferredSize(
preferredSize: const Size(200, double.infinity),
child: Container(
margin: const EdgeInsets.only(top: 16.0, bottom: 16.0, right: 16.0),
padding: const EdgeInsets.all(8.0),
child: Obx(
() => jobController.jobTable.isEmpty
? generateCard(
Center(
child: Column(
mainAxisAlignment: MainAxisAlignment.center,
children: [
SvgPicture.asset(
"assets/transfer.svg",
color: Theme.of(context).tabBarTheme.labelColor,
height: 40,
).paddingOnly(bottom: 10),
Text(
translate("No transfers in progress"),
textAlign: TextAlign.center,
textScaleFactor: 1.20,
style: TextStyle(
color:
Theme.of(context).tabBarTheme.labelColor),
),
],
), ),
), ),
), )
: statusListView(),
)),
); );
} }
@ -418,8 +410,7 @@ class _FileManagerViewState extends State<FileManagerView> {
}, },
onExit: (evt) => onExit: (evt) =>
widget._mouseFocusScope.value = MouseFocusScope.none, widget._mouseFocusScope.value = MouseFocusScope.none,
child: _buildFileList( child: _buildFileList(context, _fileListScrollController),
context, isLocal, _fileListScrollController),
)) ))
], ],
), ),
@ -864,7 +855,7 @@ class _FileManagerViewState extends State<FileManagerView> {
} }
Widget _buildFileList( Widget _buildFileList(
BuildContext context, bool isLocal, ScrollController scrollController) { BuildContext context, ScrollController scrollController) {
final fd = controller.directory.value; final fd = controller.directory.value;
final entries = fd.entries; final entries = fd.entries;
@ -1044,7 +1035,7 @@ class _FileManagerViewState extends State<FileManagerView> {
// Header // Header
Row( Row(
children: [ children: [
Expanded(child: _buildFileBrowserHeader(context, isLocal)), Expanded(child: _buildFileBrowserHeader(context)),
], ],
), ),
// Body // Body
@ -1139,7 +1130,7 @@ class _FileManagerViewState extends State<FileManagerView> {
return false; return false;
} }
Widget _buildFileBrowserHeader(BuildContext context, bool isLocal) { Widget _buildFileBrowserHeader(BuildContext context) {
final padding = EdgeInsets.all(1.0); final padding = EdgeInsets.all(1.0);
return SizedBox( return SizedBox(
height: kDesktopFileTransferHeaderHeight, height: kDesktopFileTransferHeaderHeight,
@ -1147,7 +1138,7 @@ class _FileManagerViewState extends State<FileManagerView> {
children: [ children: [
Obx( Obx(
() => headerItemFunc( () => headerItemFunc(
_nameColWidth.value, SortBy.name, translate("Name"), isLocal), _nameColWidth.value, SortBy.name, translate("Name")),
), ),
DraggableDivider( DraggableDivider(
axis: Axis.vertical, axis: Axis.vertical,
@ -1160,7 +1151,7 @@ class _FileManagerViewState extends State<FileManagerView> {
), ),
Obx( Obx(
() => headerItemFunc(_modifiedColWidth.value, SortBy.modified, () => headerItemFunc(_modifiedColWidth.value, SortBy.modified,
translate("Modified"), isLocal), translate("Modified")),
), ),
DraggableDivider( DraggableDivider(
axis: Axis.vertical, axis: Axis.vertical,
@ -1172,16 +1163,13 @@ class _FileManagerViewState extends State<FileManagerView> {
_modifiedColWidth.value)); _modifiedColWidth.value));
}, },
padding: padding), padding: padding),
Expanded( Expanded(child: headerItemFunc(null, SortBy.size, translate("Size")))
child:
headerItemFunc(null, SortBy.size, translate("Size"), isLocal))
], ],
), ),
); );
} }
Widget headerItemFunc( Widget headerItemFunc(double? width, SortBy sortBy, String name) {
double? width, SortBy sortBy, String name, bool isLocal) {
final headerTextStyle = final headerTextStyle =
Theme.of(context).dataTableTheme.headingTextStyle ?? TextStyle(); Theme.of(context).dataTableTheme.headingTextStyle ?? TextStyle();
return ObxValue<Rx<bool?>>( return ObxValue<Rx<bool?>>(
@ -1222,7 +1210,7 @@ class _FileManagerViewState extends State<FileManagerView> {
), ),
), () { ), () {
if (controller.sortBy.value == sortBy) { if (controller.sortBy.value == sortBy) {
return controller.sortAscending; return controller.sortAscending.obs;
} else { } else {
return Rx<bool?>(null); return Rx<bool?>(null);
} }

View File

@ -208,7 +208,7 @@ class FileController {
final history = RxList<String>.empty(growable: true); final history = RxList<String>.empty(growable: true);
final sortBy = SortBy.name.obs; final sortBy = SortBy.name.obs;
final sortAscending = true.obs; var sortAscending = true;
final JobController jobController; final JobController jobController;
final OverlayDialogManager? dialogManager; final OverlayDialogManager? dialogManager;
@ -285,7 +285,7 @@ class FileController {
void changeSortStyle(SortBy sort, {bool? isLocal, bool ascending = true}) { void changeSortStyle(SortBy sort, {bool? isLocal, bool ascending = true}) {
sortBy.value = sort; sortBy.value = sort;
sortAscending.value = ascending; sortAscending = ascending;
directory.value.changeSortStyle(sort, ascending: ascending); directory.value.changeSortStyle(sort, ascending: ascending);
} }
@ -592,7 +592,7 @@ class FileController {
class JobController { class JobController {
static final JobID jobID = JobID(); static final JobID jobID = JobID();
final jobTable = RxList<JobProgress>.empty(growable: true); final jobTable = List<JobProgress>.empty(growable: true).obs;
final jobResultListener = JobResultListener<Map<String, dynamic>>(); final jobResultListener = JobResultListener<Map<String, dynamic>>();
final GetSessionID getSessionID; final GetSessionID getSessionID;
String get sessionID => getSessionID(); String get sessionID => getSessionID();