refactor functions
This commit is contained in:
parent
bcd1827d8a
commit
780d64a349
@ -403,6 +403,7 @@ class _FileManagerViewState extends State<FileManagerView> {
|
|||||||
|
|
||||||
@override
|
@override
|
||||||
Widget build(BuildContext context) {
|
Widget build(BuildContext context) {
|
||||||
|
_handleColumnPorportions();
|
||||||
return Container(
|
return Container(
|
||||||
margin: const EdgeInsets.all(16.0),
|
margin: const EdgeInsets.all(16.0),
|
||||||
padding: const EdgeInsets.all(8.0),
|
padding: const EdgeInsets.all(8.0),
|
||||||
@ -434,6 +435,27 @@ class _FileManagerViewState extends State<FileManagerView> {
|
|||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void _handleColumnPorportions() {
|
||||||
|
final windowWidthNow = MediaQuery.of(context).size.width;
|
||||||
|
if (_windowWidthPrev == null) {
|
||||||
|
_windowWidthPrev = windowWidthNow;
|
||||||
|
final defaultColumnWidth = windowWidthNow * 0.115;
|
||||||
|
_fileTransferMinimumWidth = defaultColumnWidth / 3;
|
||||||
|
_nameColWidth.value = defaultColumnWidth;
|
||||||
|
_modifiedColWidth.value = defaultColumnWidth;
|
||||||
|
_sizeColWidth.value = defaultColumnWidth;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (_windowWidthPrev != windowWidthNow) {
|
||||||
|
final difference = windowWidthNow / _windowWidthPrev!;
|
||||||
|
_windowWidthPrev = windowWidthNow;
|
||||||
|
_fileTransferMinimumWidth *= difference;
|
||||||
|
_nameColWidth.value *= difference;
|
||||||
|
_modifiedColWidth.value *= difference;
|
||||||
|
_sizeColWidth.value *= difference;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
void onLocationFocusChanged() {
|
void onLocationFocusChanged() {
|
||||||
debugPrint("focus changed on local");
|
debugPrint("focus changed on local");
|
||||||
if (_locationNode.hasFocus) {
|
if (_locationNode.hasFocus) {
|
||||||
@ -1148,27 +1170,19 @@ class _FileManagerViewState extends State<FileManagerView> {
|
|||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void _onDrag(double dx, RxDouble column1, RxDouble column2) {
|
||||||
|
if (column1.value + dx <= _fileTransferMinimumWidth ||
|
||||||
|
column2.value - dx <= _fileTransferMinimumWidth) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
column1.value += dx;
|
||||||
|
column2.value -= dx;
|
||||||
|
column1.value = max(_fileTransferMinimumWidth, column1.value);
|
||||||
|
column2.value = max(_fileTransferMinimumWidth, column2.value);
|
||||||
|
}
|
||||||
|
|
||||||
Widget _buildFileBrowserHeader(BuildContext context) {
|
Widget _buildFileBrowserHeader(BuildContext context) {
|
||||||
final padding = EdgeInsets.all(1.0);
|
final padding = EdgeInsets.all(1.0);
|
||||||
final windowWidthNow = MediaQuery.of(context).size.width;
|
|
||||||
if (_windowWidthPrev == null) {
|
|
||||||
_windowWidthPrev = windowWidthNow;
|
|
||||||
final defaultColumnWidth = windowWidthNow * 0.34 / 3;
|
|
||||||
_fileTransferMinimumWidth = defaultColumnWidth / 3;
|
|
||||||
_nameColWidth.value = defaultColumnWidth;
|
|
||||||
_modifiedColWidth.value = defaultColumnWidth;
|
|
||||||
_sizeColWidth.value = defaultColumnWidth;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (_windowWidthPrev != windowWidthNow) {
|
|
||||||
final difference = windowWidthNow / _windowWidthPrev!;
|
|
||||||
_windowWidthPrev = windowWidthNow;
|
|
||||||
_fileTransferMinimumWidth *= difference;
|
|
||||||
_nameColWidth.value *= difference;
|
|
||||||
_modifiedColWidth.value *= difference;
|
|
||||||
_sizeColWidth.value *= difference;
|
|
||||||
}
|
|
||||||
|
|
||||||
return SizedBox(
|
return SizedBox(
|
||||||
key: _globalHeaderKey,
|
key: _globalHeaderKey,
|
||||||
height: kDesktopFileTransferHeaderHeight,
|
height: kDesktopFileTransferHeaderHeight,
|
||||||
@ -1180,22 +1194,8 @@ class _FileManagerViewState extends State<FileManagerView> {
|
|||||||
),
|
),
|
||||||
DraggableDivider(
|
DraggableDivider(
|
||||||
axis: Axis.vertical,
|
axis: Axis.vertical,
|
||||||
onPointerMove: (dx) {
|
onPointerMove: (dx) =>
|
||||||
if (_nameColWidth.value + dx <= _fileTransferMinimumWidth) {
|
_onDrag(dx, _nameColWidth, _modifiedColWidth),
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (_modifiedColWidth.value - dx <= _fileTransferMinimumWidth) {
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
_nameColWidth.value += dx;
|
|
||||||
_nameColWidth.value =
|
|
||||||
max(_fileTransferMinimumWidth, _nameColWidth.value);
|
|
||||||
_modifiedColWidth.value -= dx;
|
|
||||||
_modifiedColWidth.value =
|
|
||||||
max(_fileTransferMinimumWidth, _modifiedColWidth.value);
|
|
||||||
},
|
|
||||||
padding: padding,
|
padding: padding,
|
||||||
),
|
),
|
||||||
Obx(
|
Obx(
|
||||||
@ -1204,22 +1204,8 @@ class _FileManagerViewState extends State<FileManagerView> {
|
|||||||
),
|
),
|
||||||
DraggableDivider(
|
DraggableDivider(
|
||||||
axis: Axis.vertical,
|
axis: Axis.vertical,
|
||||||
onPointerMove: (dx) {
|
onPointerMove: (dx) =>
|
||||||
if (_modifiedColWidth.value + dx <= _fileTransferMinimumWidth) {
|
_onDrag(dx, _modifiedColWidth, _sizeColWidth),
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (_sizeColWidth.value - dx <= _fileTransferMinimumWidth) {
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
_modifiedColWidth.value += dx;
|
|
||||||
_modifiedColWidth.value =
|
|
||||||
max(_fileTransferMinimumWidth, _modifiedColWidth.value);
|
|
||||||
_sizeColWidth.value -= dx;
|
|
||||||
_sizeColWidth.value =
|
|
||||||
max(_fileTransferMinimumWidth, _sizeColWidth.value);
|
|
||||||
},
|
|
||||||
padding: padding),
|
padding: padding),
|
||||||
Expanded(
|
Expanded(
|
||||||
child: headerItemFunc(
|
child: headerItemFunc(
|
||||||
|
Loading…
x
Reference in New Issue
Block a user