replace Wrap with builder in PeerView for efficiency
Signed-off-by: 21pages <pages21@163.com>
This commit is contained in:
parent
0246f050e2
commit
0c6aa381c5
.github/workflows
flutter
1
.github/workflows/flutter-build.yml
vendored
1
.github/workflows/flutter-build.yml
vendored
@ -82,6 +82,7 @@ jobs:
|
|||||||
|
|
||||||
- name: Install flutter rust bridge deps
|
- name: Install flutter rust bridge deps
|
||||||
run: |
|
run: |
|
||||||
|
git config --global core.longpaths true
|
||||||
cargo install flutter_rust_bridge_codegen --version ${{ env.FLUTTER_RUST_BRIDGE_VERSION }} --features "uuid"
|
cargo install flutter_rust_bridge_codegen --version ${{ env.FLUTTER_RUST_BRIDGE_VERSION }} --features "uuid"
|
||||||
Push-Location flutter ; flutter pub get ; Pop-Location
|
Push-Location flutter ; flutter pub get ; Pop-Location
|
||||||
~/.cargo/bin/flutter_rust_bridge_codegen --rust-input ./src/flutter_ffi.rs --dart-output ./flutter/lib/generated_bridge.dart
|
~/.cargo/bin/flutter_rust_bridge_codegen --rust-input ./src/flutter_ffi.rs --dart-output ./flutter/lib/generated_bridge.dart
|
||||||
|
@ -1,6 +1,7 @@
|
|||||||
import 'dart:async';
|
import 'dart:async';
|
||||||
import 'dart:collection';
|
import 'dart:collection';
|
||||||
|
|
||||||
|
import 'package:dynamic_layouts/dynamic_layouts.dart';
|
||||||
import 'package:flutter/foundation.dart';
|
import 'package:flutter/foundation.dart';
|
||||||
import 'package:flutter/material.dart';
|
import 'package:flutter/material.dart';
|
||||||
import 'package:get/get.dart';
|
import 'package:get/get.dart';
|
||||||
@ -177,26 +178,29 @@ class _PeersViewState extends State<_PeersView> with WindowListener {
|
|||||||
if (snapshot.hasData) {
|
if (snapshot.hasData) {
|
||||||
final peers = snapshot.data!;
|
final peers = snapshot.data!;
|
||||||
gFFI.peerTabModel.setCurrentTabCachedPeers(peers);
|
gFFI.peerTabModel.setCurrentTabCachedPeers(peers);
|
||||||
final cards = <Widget>[];
|
final child = DynamicGridView.builder(
|
||||||
for (final peer in peers) {
|
gridDelegate: SliverGridDelegateWithWrapping(
|
||||||
final visibilityChild = VisibilityDetector(
|
mainAxisSpacing: space / 2, crossAxisSpacing: space),
|
||||||
key: ValueKey(_cardId(peer.id)),
|
itemCount: peers.length,
|
||||||
onVisibilityChanged: onVisibilityChanged,
|
itemBuilder: (BuildContext context, int index) {
|
||||||
child: widget.peerCardBuilder(peer),
|
final visibilityChild = VisibilityDetector(
|
||||||
);
|
key: ValueKey(_cardId(peers[index].id)),
|
||||||
cards.add(isDesktop
|
onVisibilityChanged: onVisibilityChanged,
|
||||||
? Obx(
|
child: widget.peerCardBuilder(peers[index]),
|
||||||
() => SizedBox(
|
);
|
||||||
width: 220,
|
return isDesktop
|
||||||
height:
|
? Obx(
|
||||||
peerCardUiType.value == PeerUiType.grid ? 140 : 42,
|
() => SizedBox(
|
||||||
child: visibilityChild,
|
width: 220,
|
||||||
),
|
height: peerCardUiType.value == PeerUiType.grid
|
||||||
)
|
? 140
|
||||||
: SizedBox(width: mobileWidth, child: visibilityChild));
|
: 42,
|
||||||
}
|
child: visibilityChild,
|
||||||
final child =
|
),
|
||||||
Wrap(spacing: space, runSpacing: space, children: cards);
|
)
|
||||||
|
: SizedBox(width: mobileWidth, child: visibilityChild);
|
||||||
|
},
|
||||||
|
);
|
||||||
if (updateEvent == UpdateEvent.load) {
|
if (updateEvent == UpdateEvent.load) {
|
||||||
_curPeers.clear();
|
_curPeers.clear();
|
||||||
_curPeers.addAll(peers.map((e) => e.id));
|
_curPeers.addAll(peers.map((e) => e.id));
|
||||||
|
@ -138,7 +138,7 @@ class _ConnectionPageState extends State<ConnectionPage>
|
|||||||
Divider().paddingOnly(right: 12),
|
Divider().paddingOnly(right: 12),
|
||||||
])),
|
])),
|
||||||
SliverFillRemaining(
|
SliverFillRemaining(
|
||||||
hasScrollBody: false,
|
hasScrollBody: true,
|
||||||
child: PeerTabPage().paddingOnly(right: 12.0),
|
child: PeerTabPage().paddingOnly(right: 12.0),
|
||||||
)
|
)
|
||||||
],
|
],
|
||||||
|
@ -328,7 +328,7 @@ packages:
|
|||||||
description:
|
description:
|
||||||
path: "."
|
path: "."
|
||||||
ref: HEAD
|
ref: HEAD
|
||||||
resolved-ref: "e51fddf7f3b46d4423b7aa79ba824a45a1ea1b7a"
|
resolved-ref: e51fddf7f3b46d4423b7aa79ba824a45a1ea1b7a
|
||||||
url: "https://github.com/rustdesk-org/rustdesk_desktop_multi_window"
|
url: "https://github.com/rustdesk-org/rustdesk_desktop_multi_window"
|
||||||
source: git
|
source: git
|
||||||
version: "0.1.0"
|
version: "0.1.0"
|
||||||
@ -396,6 +396,15 @@ packages:
|
|||||||
url: "https://pub.dev"
|
url: "https://pub.dev"
|
||||||
source: hosted
|
source: hosted
|
||||||
version: "2.0.0"
|
version: "2.0.0"
|
||||||
|
dynamic_layouts:
|
||||||
|
dependency: "direct main"
|
||||||
|
description:
|
||||||
|
path: "packages/dynamic_layouts"
|
||||||
|
ref: "0023d01996576e494094793a6552463f01c5627a"
|
||||||
|
resolved-ref: "0023d01996576e494094793a6552463f01c5627a"
|
||||||
|
url: "https://github.com/flutter/packages.git"
|
||||||
|
source: git
|
||||||
|
version: "0.0.1+1"
|
||||||
event_bus:
|
event_bus:
|
||||||
dependency: transitive
|
dependency: transitive
|
||||||
description:
|
description:
|
||||||
|
@ -100,6 +100,11 @@ dependencies:
|
|||||||
uuid: ^3.0.7
|
uuid: ^3.0.7
|
||||||
auto_size_text_field: ^2.2.1
|
auto_size_text_field: ^2.2.1
|
||||||
flex_color_picker: ^3.3.0
|
flex_color_picker: ^3.3.0
|
||||||
|
dynamic_layouts:
|
||||||
|
git:
|
||||||
|
url: https://github.com/flutter/packages.git
|
||||||
|
path: packages/dynamic_layouts
|
||||||
|
ref: 0023d01996576e494094793a6552463f01c5627a
|
||||||
|
|
||||||
dev_dependencies:
|
dev_dependencies:
|
||||||
icons_launcher: ^2.0.4
|
icons_launcher: ^2.0.4
|
||||||
|
Loading…
x
Reference in New Issue
Block a user