Skip to content

Commit

Permalink
发布v1.1.1
Browse files Browse the repository at this point in the history
  • Loading branch information
mapleafgo committed May 11, 2023
1 parent 895d539 commit b262623
Showing 1 changed file with 19 additions and 7 deletions.
26 changes: 19 additions & 7 deletions lib/app/pages/connections/connections_page.dart
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ import 'package:clash_for_flutter/app/source/request.dart';
import 'package:clash_for_flutter/app/utils/utils.dart';
import 'package:data_table_2/data_table_2.dart';
import 'package:flutter/material.dart';
import 'package:flutter/rendering.dart';
import 'package:flutter_modular/flutter_modular.dart';
import 'package:timeago/timeago.dart' as timeago;

Expand All @@ -25,6 +26,7 @@ class _ConnectionsPageState extends State<ConnectionsPage> {
StreamSubscription? _subscription;
Snapshot _snapshot = Snapshot.empty();
List<ConnectionShow> _data = [];
bool _showFab = true;

@override
void initState() {
Expand All @@ -36,6 +38,7 @@ class _ConnectionsPageState extends State<ConnectionsPage> {
_snapshot = newSnapshot;
});
});
_controller.addListener(_scrollListener);
}

@override
Expand All @@ -46,6 +49,15 @@ class _ConnectionsPageState extends State<ConnectionsPage> {
super.dispose();
}

void _scrollListener() {
if (_controller.position.userScrollDirection == ScrollDirection.reverse && _showFab) {
setState(() => _showFab = false);
}
if (_controller.position.userScrollDirection == ScrollDirection.forward && !_showFab) {
setState(() => _showFab = true);
}
}

List<ConnectionShow> toShow(List<Connection> oldValue, List<Connection> newValue) {
var result = <ConnectionShow>[];
for (var c in newValue) {
Expand Down Expand Up @@ -242,13 +254,6 @@ class _ConnectionsPageState extends State<ConnectionsPage> {
),
],
),
actions: [
IconButton(
tooltip: "断开所有连接",
icon: const Icon(Icons.clear_all),
onPressed: () => _request.closeAllConnections(),
),
],
),
body: Stack(
children: [
Expand Down Expand Up @@ -342,6 +347,13 @@ class _ConnectionsPageState extends State<ConnectionsPage> {
)
],
),
floatingActionButton: _showFab
? FloatingActionButton(
tooltip: "断开所有连接",
child: const Icon(Icons.clear_all),
onPressed: () => _request.closeAllConnections(),
)
: null,
);
}
}

0 comments on commit b262623

Please sign in to comment.