#54 fix order
This commit is contained in:
@@ -47,6 +47,8 @@ class _HomePageState extends State<HomePage>
|
||||
final _selectIndex = ValueNotifier(0);
|
||||
late S _s;
|
||||
|
||||
bool _switchingPage = false;
|
||||
|
||||
@override
|
||||
void initState() {
|
||||
super.initState();
|
||||
@@ -119,12 +121,18 @@ class _HomePageState extends State<HomePage>
|
||||
],
|
||||
),
|
||||
body: PageView.builder(
|
||||
physics: const NeverScrollableScrollPhysics(),
|
||||
controller: _pageController,
|
||||
itemBuilder: (_, index) => AppTab.values[index].page,
|
||||
onPageChanged: (value) {
|
||||
if (!_switchingPage) {
|
||||
_selectIndex.value = value;
|
||||
}
|
||||
},
|
||||
),
|
||||
bottomNavigationBar: ValueBuilder(
|
||||
listenable: _selectIndex,
|
||||
build: _buildBottomBar,
|
||||
),
|
||||
bottomNavigationBar:
|
||||
ValueBuilder(listenable: _selectIndex, build: _buildBottomBar),
|
||||
);
|
||||
}
|
||||
|
||||
@@ -133,12 +141,17 @@ class _HomePageState extends State<HomePage>
|
||||
selectedIndex: _selectIndex.value,
|
||||
animationDuration: const Duration(milliseconds: 250),
|
||||
onDestinationSelected: (int index) {
|
||||
if (_selectIndex.value == index) return;
|
||||
_selectIndex.value = index;
|
||||
_switchingPage = true;
|
||||
_pageController.animateToPage(
|
||||
index,
|
||||
duration: const Duration(milliseconds: 677),
|
||||
curve: Curves.fastLinearToSlowEaseIn,
|
||||
);
|
||||
Future.delayed(const Duration(milliseconds: 677), () {
|
||||
_switchingPage = false;
|
||||
});
|
||||
},
|
||||
labelBehavior: NavigationDestinationLabelBehavior.onlyShowSelected,
|
||||
destinations: [
|
||||
|
||||
@@ -10,6 +10,7 @@ import 'package:toolbox/core/utils/misc.dart';
|
||||
import 'package:toolbox/data/model/server/snippet.dart';
|
||||
import 'package:toolbox/data/provider/snippet.dart';
|
||||
import 'package:toolbox/view/page/process.dart';
|
||||
import 'package:toolbox/view/widget/fade_in.dart';
|
||||
import 'package:toolbox/view/widget/tag/picker.dart';
|
||||
import 'package:toolbox/view/widget/tag/switcher.dart';
|
||||
|
||||
@@ -117,15 +118,18 @@ class _ServerPageState extends State<ServerPage>
|
||||
),
|
||||
padding: const EdgeInsets.fromLTRB(7, 10, 7, 7),
|
||||
onReorder: (oldIndex, newIndex) => setState(() {
|
||||
pro.serverOrder.moveById(
|
||||
filtered[oldIndex],
|
||||
filtered[newIndex],
|
||||
pro.serverOrder.moveByItem(
|
||||
filtered,
|
||||
oldIndex,
|
||||
newIndex,
|
||||
property: _settingStore.serverOrder,
|
||||
);
|
||||
}),
|
||||
itemBuilder: (_, index) => _buildEachServerCard(
|
||||
pro.servers[filtered[index]],
|
||||
),
|
||||
itemBuilder: (_, index) => FadeIn(
|
||||
key: ValueKey('$_tag${filtered[index]}'),
|
||||
child: _buildEachServerCard(
|
||||
pro.servers[filtered[index]],
|
||||
)),
|
||||
itemCount: filtered.length,
|
||||
);
|
||||
},
|
||||
|
||||
@@ -120,7 +120,9 @@ class _SnippetEditPageState extends State<SnippetEditPage>
|
||||
}),
|
||||
s: _s,
|
||||
tagSuggestions: [..._provider.tags],
|
||||
onRenameTag: _provider.renameTag,
|
||||
onRenameTag: (old, n) => setState(() {
|
||||
_provider.renameTag(old, n);
|
||||
}),
|
||||
)
|
||||
],
|
||||
);
|
||||
|
||||
@@ -4,6 +4,7 @@ import 'package:provider/provider.dart';
|
||||
import 'package:toolbox/core/extension/order.dart';
|
||||
import 'package:toolbox/data/model/server/server.dart';
|
||||
import 'package:toolbox/data/provider/server.dart';
|
||||
import 'package:toolbox/data/res/ui.dart';
|
||||
import 'package:toolbox/view/widget/tag/switcher.dart';
|
||||
|
||||
import '../../../core/utils/misc.dart';
|
||||
@@ -71,9 +72,10 @@ class _SnippetListPageState extends State<SnippetListPage> {
|
||||
padding: const EdgeInsets.all(13),
|
||||
itemCount: filtered.length,
|
||||
onReorder: (oldIdx, newIdx) => setState(() {
|
||||
provider.snippets.moveById(
|
||||
filtered[oldIdx],
|
||||
filtered[newIdx],
|
||||
provider.snippets.moveByItem(
|
||||
filtered,
|
||||
oldIdx,
|
||||
newIdx,
|
||||
onMove: (p0) {
|
||||
_settingStore.snippetOrder.put(p0.map((e) => e.name).toList());
|
||||
},
|
||||
@@ -87,7 +89,7 @@ class _SnippetListPageState extends State<SnippetListPage> {
|
||||
width: _media.size.width,
|
||||
),
|
||||
itemBuilder: (context, idx) {
|
||||
final snippet = filtered[idx];
|
||||
final snippet = filtered.elementAt(idx);
|
||||
return RoundRectCard(
|
||||
ListTile(
|
||||
contentPadding: const EdgeInsets.only(left: 23, right: 17),
|
||||
@@ -96,6 +98,12 @@ class _SnippetListPageState extends State<SnippetListPage> {
|
||||
overflow: TextOverflow.ellipsis,
|
||||
maxLines: 1,
|
||||
),
|
||||
subtitle: Text(
|
||||
snippet.script,
|
||||
overflow: TextOverflow.ellipsis,
|
||||
maxLines: 1,
|
||||
style: grey,
|
||||
),
|
||||
trailing: Row(
|
||||
mainAxisSize: MainAxisSize.min,
|
||||
children: [
|
||||
|
||||
@@ -58,7 +58,7 @@ class _SSHVirtKeySettingPageState extends State<SSHVirtKeySettingPage> {
|
||||
showSnackBar(context, Text(_s.disabled));
|
||||
return;
|
||||
}
|
||||
keys.moveById(keys[o], keys[n], property: _setting.sshVirtKeys);
|
||||
keys.moveByItem(keys, o, n, property: _setting.sshVirtKeys);
|
||||
setState(() {});
|
||||
},
|
||||
);
|
||||
|
||||
@@ -8,7 +8,7 @@ class FadeIn extends StatefulWidget {
|
||||
const FadeIn({
|
||||
Key? key,
|
||||
required this.child,
|
||||
this.duration = const Duration(milliseconds: 377),
|
||||
this.duration = const Duration(milliseconds: 477),
|
||||
}) : super(key: key);
|
||||
|
||||
@override
|
||||
|
||||
@@ -1,5 +1,6 @@
|
||||
import 'package:flutter/material.dart';
|
||||
import 'package:nil/nil.dart';
|
||||
import 'package:toolbox/view/widget/fade_in.dart';
|
||||
import 'package:toolbox/view/widget/tag/view.dart';
|
||||
|
||||
class TagSwitcher extends StatelessWidget {
|
||||
@@ -20,10 +21,6 @@ class TagSwitcher extends StatelessWidget {
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
return _buildTagsSwitcher(tags);
|
||||
}
|
||||
|
||||
Widget _buildTagsSwitcher(List<String> tags) {
|
||||
if (tags.isEmpty) return nil;
|
||||
final items = <String?>[null, ...tags];
|
||||
return Container(
|
||||
@@ -35,11 +32,14 @@ class TagSwitcher extends StatelessWidget {
|
||||
scrollDirection: Axis.horizontal,
|
||||
itemBuilder: (context, index) {
|
||||
final item = items[index];
|
||||
return TagView(
|
||||
tag: item,
|
||||
initTag: initTag,
|
||||
all: all,
|
||||
onTap: onTagChanged,
|
||||
return FadeIn(
|
||||
key: ValueKey(initTag),
|
||||
child: TagView(
|
||||
tag: item,
|
||||
initTag: initTag,
|
||||
all: all,
|
||||
onTap: onTagChanged,
|
||||
),
|
||||
);
|
||||
},
|
||||
itemCount: items.length,
|
||||
|
||||
Reference in New Issue
Block a user