Skip to content

Commit

Permalink
fix: offset reorder index (#448)
Browse files Browse the repository at this point in the history
  • Loading branch information
poppingmoon authored Oct 26, 2024
1 parent 15e19dc commit 99949f3
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 6 deletions.
9 changes: 6 additions & 3 deletions lib/view/page/settings/accounts_page.dart
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
import 'dart:math';
import 'dart:ui';

import 'package:flutter/material.dart';
Expand Down Expand Up @@ -58,9 +59,11 @@ class AccountsPage extends HookConsumerWidget {
}
},
itemCount: accounts.length + 2,
onReorder: (oldIndex, newIndex) => ref
.read(accountsNotifierProvider.notifier)
.reorder(oldIndex, newIndex),
onReorder: (oldIndex, newIndex) =>
ref.read(accountsNotifierProvider.notifier).reorder(
max(0, oldIndex - 1),
min(newIndex - 1, accounts.length),
),
proxyDecorator: (child, _, animation) => AnimatedBuilder(
animation: animation,
builder: (context, child) {
Expand Down
8 changes: 5 additions & 3 deletions lib/view/page/settings/tabs_page.dart
Original file line number Diff line number Diff line change
Expand Up @@ -64,9 +64,11 @@ class TabsPage extends HookConsumerWidget {
}
},
itemCount: tabs.length + 2,
onReorder: (oldIndex, newIndex) => ref
.read(timelineTabsNotifierProvider.notifier)
.reorder(oldIndex, min(newIndex, tabs.length)),
onReorder: (oldIndex, newIndex) =>
ref.read(timelineTabsNotifierProvider.notifier).reorder(
max(0, oldIndex - 1),
min(newIndex - 1, tabs.length),
),
proxyDecorator: (child, _, animation) => AnimatedBuilder(
animation: animation,
builder: (context, child) {
Expand Down

0 comments on commit 99949f3

Please sign in to comment.