refactor(notes): Improve code formatting and replace platform-specific refresh controls

This commit is contained in:
cogwheel0
2025-12-15 11:46:48 +05:30
parent c21e70396d
commit dcb73215a4
4 changed files with 93 additions and 35 deletions

View File

@@ -2030,6 +2030,10 @@ class _ChatPageState extends ConsumerState<ChatPage> {
// Messages Area fills entire space with pull-to-refresh
Positioned.fill(
child: ConduitRefreshIndicator(
// Position indicator below the floating app bar
edgeOffset:
MediaQuery.of(context).padding.top +
kToolbarHeight,
onRefresh: () async {
// Reload active conversation messages from server
final api = ref.read(apiServiceProvider);

View File

@@ -13,6 +13,7 @@ import '../../../shared/theme/theme_extensions.dart';
import '../../chat/providers/chat_providers.dart' as chat;
import '../../../core/utils/debug_logger.dart';
import '../../../core/services/navigation_service.dart';
import '../../../shared/widgets/loading_states.dart';
import '../../../shared/widgets/themed_dialogs.dart';
import 'package:conduit/l10n/app_localizations.dart';
import '../../../core/utils/user_display_name.dart';
@@ -112,19 +113,6 @@ class _ChatsDrawerState extends ConsumerState<ChatsDrawer> {
// Legacy helper removed: drawer now uses slivers with lazy delegates.
Widget _buildRefreshableScrollableSlivers({required List<Widget> slivers}) {
if (Platform.isIOS) {
final scroll = CustomScrollView(
key: const PageStorageKey<String>('chats_drawer_scroll'),
controller: _listController,
physics: const AlwaysScrollableScrollPhysics(),
slivers: [
CupertinoSliverRefreshControl(onRefresh: _refreshChats),
...slivers,
],
);
return CupertinoScrollbar(controller: _listController, child: scroll);
}
final scroll = CustomScrollView(
key: const PageStorageKey<String>('chats_drawer_scroll'),
controller: _listController,
@@ -132,10 +120,20 @@ class _ChatsDrawerState extends ConsumerState<ChatsDrawer> {
cacheExtent: 800,
slivers: slivers,
);
return RefreshIndicator(
final refreshableScroll = ConduitRefreshIndicator(
onRefresh: _refreshChats,
child: Scrollbar(controller: _listController, child: scroll),
child: scroll,
);
if (Platform.isIOS) {
return CupertinoScrollbar(
controller: _listController,
child: refreshableScroll,
);
}
return Scrollbar(controller: _listController, child: refreshableScroll);
}
@override

View File

@@ -16,6 +16,7 @@ import '../../../core/widgets/error_boundary.dart';
import '../../../shared/theme/theme_extensions.dart';
import '../../../shared/utils/ui_utils.dart';
import '../../../shared/widgets/improved_loading_states.dart';
import '../../../shared/widgets/loading_states.dart';
import '../../../shared/widgets/themed_dialogs.dart';
import '../../../shared/widgets/middle_ellipsis_text.dart';
import '../../../shared/utils/conversation_context_menu.dart';
@@ -346,18 +347,7 @@ class _NotesListPageState extends ConsumerState<NotesListPage> {
}
Widget _buildRefreshableScrollView(List<Widget> slivers) {
if (Platform.isIOS) {
return CustomScrollView(
controller: _scrollController,
physics: const AlwaysScrollableScrollPhysics(),
slivers: [
CupertinoSliverRefreshControl(onRefresh: _refreshNotes),
...slivers,
],
);
}
return RefreshIndicator(
return ConduitRefreshIndicator(
onRefresh: _refreshNotes,
child: CustomScrollView(
controller: _scrollController,
@@ -551,7 +541,9 @@ class _NotesListPageState extends ConsumerState<NotesListPage> {
Text(
preview,
style: AppTypography.bodySmallStyle.copyWith(
color: sidebarTheme.foreground.withValues(alpha: 0.6),
color: sidebarTheme.foreground.withValues(
alpha: 0.6,
),
height: 1.4,
),
maxLines: 2,
@@ -566,23 +558,30 @@ class _NotesListPageState extends ConsumerState<NotesListPage> {
Platform.isIOS
? CupertinoIcons.clock
: Icons.schedule_rounded,
color: sidebarTheme.foreground.withValues(alpha: 0.4),
color: sidebarTheme.foreground.withValues(
alpha: 0.4,
),
size: 12,
),
const SizedBox(width: 4),
Text(
timeText,
style: AppTypography.tiny.copyWith(
color: sidebarTheme.foreground.withValues(alpha: 0.5),
color: sidebarTheme.foreground.withValues(
alpha: 0.5,
),
fontWeight: FontWeight.w500,
),
),
if (note.user != null && note.user!.name != null) ...[
if (note.user != null &&
note.user!.name != null) ...[
const SizedBox(width: Spacing.sm),
Text(
'·',
style: AppTypography.tiny.copyWith(
color: sidebarTheme.foreground.withValues(alpha: 0.3),
color: sidebarTheme.foreground.withValues(
alpha: 0.3,
),
),
),
const SizedBox(width: Spacing.sm),
@@ -590,7 +589,9 @@ class _NotesListPageState extends ConsumerState<NotesListPage> {
child: Text(
note.user!.name!,
style: AppTypography.tiny.copyWith(
color: sidebarTheme.foreground.withValues(alpha: 0.5),
color: sidebarTheme.foreground.withValues(
alpha: 0.5,
),
fontWeight: FontWeight.w500,
),
overflow: TextOverflow.ellipsis,
@@ -618,7 +619,8 @@ class _NotesListPageState extends ConsumerState<NotesListPage> {
minWidth: TouchTarget.badge,
minHeight: TouchTarget.badge,
),
onPressed: () => _showNoteContextMenu(buttonContext, note),
onPressed: () =>
_showNoteContextMenu(buttonContext, note),
),
),
],