2025-08-10 01:20:45 +05:30
|
|
|
import 'package:flutter/material.dart';
|
2025-08-21 23:56:47 +05:30
|
|
|
import 'package:flutter/services.dart';
|
2025-08-10 01:20:45 +05:30
|
|
|
import '../../../shared/theme/theme_extensions.dart';
|
|
|
|
|
import 'package:flutter/cupertino.dart';
|
|
|
|
|
import 'package:flutter_riverpod/flutter_riverpod.dart';
|
|
|
|
|
import 'package:flutter_animate/flutter_animate.dart';
|
|
|
|
|
import 'package:package_info_plus/package_info_plus.dart';
|
|
|
|
|
import 'package:url_launcher/url_launcher_string.dart';
|
2025-08-23 20:09:43 +05:30
|
|
|
import 'package:conduit/l10n/app_localizations.dart';
|
2025-08-10 01:20:45 +05:30
|
|
|
import '../../../core/widgets/error_boundary.dart';
|
|
|
|
|
import '../../../shared/widgets/improved_loading_states.dart';
|
|
|
|
|
|
|
|
|
|
import '../../../shared/utils/ui_utils.dart';
|
2025-08-22 01:24:04 +05:30
|
|
|
import '../../../shared/widgets/sheet_handle.dart';
|
2025-08-10 01:20:45 +05:30
|
|
|
import '../../../shared/widgets/conduit_components.dart';
|
|
|
|
|
import '../../../core/providers/app_providers.dart';
|
|
|
|
|
import '../../auth/providers/unified_auth_providers.dart';
|
2025-08-17 17:01:06 +05:30
|
|
|
import '../../../core/services/settings_service.dart';
|
|
|
|
|
import '../../../core/models/model.dart';
|
|
|
|
|
import 'dart:async';
|
|
|
|
|
import 'dart:io';
|
|
|
|
|
import '../../chat/views/chat_page_helpers.dart';
|
2025-08-10 01:20:45 +05:30
|
|
|
|
|
|
|
|
/// Profile page (You tab) showing user info and main actions
|
|
|
|
|
/// Enhanced with production-grade design tokens for better cohesion
|
|
|
|
|
class ProfilePage extends ConsumerWidget {
|
|
|
|
|
const ProfilePage({super.key});
|
|
|
|
|
|
|
|
|
|
@override
|
|
|
|
|
Widget build(BuildContext context, WidgetRef ref) {
|
|
|
|
|
final user = ref.watch(currentUserProvider);
|
|
|
|
|
|
|
|
|
|
return ErrorBoundary(
|
|
|
|
|
child: user.when(
|
|
|
|
|
data: (userData) => Scaffold(
|
|
|
|
|
backgroundColor: context.conduitTheme.surfaceBackground,
|
|
|
|
|
appBar: AppBar(
|
|
|
|
|
backgroundColor: context.conduitTheme.surfaceBackground,
|
|
|
|
|
elevation: Elevation.none,
|
|
|
|
|
automaticallyImplyLeading: false,
|
2025-08-11 15:49:53 +05:30
|
|
|
leading: IconButton(
|
|
|
|
|
icon: Icon(
|
|
|
|
|
UiUtils.platformIcon(
|
|
|
|
|
ios: CupertinoIcons.back,
|
|
|
|
|
android: Icons.arrow_back,
|
|
|
|
|
),
|
|
|
|
|
color: context.conduitTheme.textPrimary,
|
|
|
|
|
),
|
|
|
|
|
onPressed: () => Navigator.of(context).maybePop(),
|
2025-08-23 20:09:43 +05:30
|
|
|
tooltip: AppLocalizations.of(context)!.back,
|
2025-08-11 15:49:53 +05:30
|
|
|
),
|
2025-08-10 01:20:45 +05:30
|
|
|
toolbarHeight: kToolbarHeight,
|
|
|
|
|
titleSpacing: 0.0,
|
2025-08-22 01:24:04 +05:30
|
|
|
title: Text(
|
2025-08-23 20:09:43 +05:30
|
|
|
AppLocalizations.of(context)!.you,
|
2025-08-22 01:24:04 +05:30
|
|
|
style: AppTypography.headlineSmallStyle.copyWith(
|
|
|
|
|
color: context.conduitTheme.textPrimary,
|
|
|
|
|
fontWeight: FontWeight.w600,
|
|
|
|
|
),
|
2025-08-10 01:20:45 +05:30
|
|
|
),
|
|
|
|
|
centerTitle: true,
|
|
|
|
|
),
|
|
|
|
|
body: SingleChildScrollView(
|
|
|
|
|
padding: const EdgeInsets.all(Spacing.pagePadding),
|
|
|
|
|
child: Column(
|
|
|
|
|
crossAxisAlignment: CrossAxisAlignment.start,
|
|
|
|
|
children: [
|
|
|
|
|
// Profile Header - Enhanced with better spacing and animations
|
|
|
|
|
_buildProfileHeader(userData)
|
|
|
|
|
.animate()
|
|
|
|
|
.fadeIn(duration: AnimationDuration.pageTransition)
|
|
|
|
|
.slideY(
|
|
|
|
|
begin: 0.1,
|
|
|
|
|
end: 0,
|
|
|
|
|
curve: AnimationCurves.pageTransition,
|
|
|
|
|
),
|
|
|
|
|
const SizedBox(height: Spacing.sectionGap),
|
|
|
|
|
|
|
|
|
|
// Account Section - Enhanced with improved spacing
|
|
|
|
|
_buildAccountSection(context, ref)
|
|
|
|
|
.animate()
|
|
|
|
|
.fadeIn(
|
|
|
|
|
delay: AnimationDelay.short,
|
|
|
|
|
duration: AnimationDuration.pageTransition,
|
|
|
|
|
)
|
|
|
|
|
.slideY(
|
|
|
|
|
begin: 0.1,
|
|
|
|
|
end: 0,
|
|
|
|
|
curve: AnimationCurves.pageTransition,
|
|
|
|
|
),
|
|
|
|
|
],
|
|
|
|
|
),
|
|
|
|
|
),
|
|
|
|
|
),
|
|
|
|
|
loading: () => Scaffold(
|
|
|
|
|
backgroundColor: context.conduitTheme.surfaceBackground,
|
|
|
|
|
appBar: AppBar(
|
|
|
|
|
backgroundColor: context.conduitTheme.surfaceBackground,
|
|
|
|
|
elevation: Elevation.none,
|
|
|
|
|
automaticallyImplyLeading: false,
|
2025-08-11 15:49:53 +05:30
|
|
|
leading: IconButton(
|
|
|
|
|
icon: Icon(
|
|
|
|
|
UiUtils.platformIcon(
|
|
|
|
|
ios: CupertinoIcons.back,
|
|
|
|
|
android: Icons.arrow_back,
|
|
|
|
|
),
|
|
|
|
|
color: context.conduitTheme.textPrimary,
|
|
|
|
|
),
|
|
|
|
|
onPressed: () => Navigator.of(context).maybePop(),
|
2025-08-23 20:09:43 +05:30
|
|
|
tooltip: AppLocalizations.of(context)!.back,
|
2025-08-11 15:49:53 +05:30
|
|
|
),
|
2025-08-10 01:20:45 +05:30
|
|
|
title: Text(
|
2025-08-23 20:09:43 +05:30
|
|
|
AppLocalizations.of(context)!.you,
|
2025-08-22 01:24:04 +05:30
|
|
|
style: AppTypography.headlineSmallStyle.copyWith(
|
2025-08-10 01:20:45 +05:30
|
|
|
color: context.conduitTheme.textPrimary,
|
|
|
|
|
fontWeight: FontWeight.w600,
|
|
|
|
|
),
|
|
|
|
|
),
|
|
|
|
|
centerTitle: true,
|
|
|
|
|
),
|
2025-08-23 20:09:43 +05:30
|
|
|
body: Center(
|
2025-08-24 20:27:11 +05:30
|
|
|
child: ImprovedLoadingState(
|
|
|
|
|
message: AppLocalizations.of(context)!.loadingProfile,
|
|
|
|
|
),
|
2025-08-10 01:20:45 +05:30
|
|
|
),
|
|
|
|
|
),
|
|
|
|
|
error: (error, stack) => Scaffold(
|
|
|
|
|
backgroundColor: context.conduitTheme.surfaceBackground,
|
|
|
|
|
appBar: AppBar(
|
|
|
|
|
backgroundColor: context.conduitTheme.surfaceBackground,
|
|
|
|
|
elevation: Elevation.none,
|
|
|
|
|
automaticallyImplyLeading: false,
|
2025-08-11 15:49:53 +05:30
|
|
|
leading: IconButton(
|
|
|
|
|
icon: Icon(
|
|
|
|
|
UiUtils.platformIcon(
|
|
|
|
|
ios: CupertinoIcons.back,
|
|
|
|
|
android: Icons.arrow_back,
|
|
|
|
|
),
|
|
|
|
|
color: context.conduitTheme.textPrimary,
|
|
|
|
|
),
|
|
|
|
|
onPressed: () => Navigator.of(context).maybePop(),
|
2025-08-23 20:09:43 +05:30
|
|
|
tooltip: AppLocalizations.of(context)!.back,
|
2025-08-11 15:49:53 +05:30
|
|
|
),
|
2025-08-10 01:20:45 +05:30
|
|
|
title: Text(
|
2025-08-23 20:09:43 +05:30
|
|
|
AppLocalizations.of(context)!.you,
|
2025-08-22 01:24:04 +05:30
|
|
|
style: AppTypography.headlineSmallStyle.copyWith(
|
2025-08-10 01:20:45 +05:30
|
|
|
color: context.conduitTheme.textPrimary,
|
|
|
|
|
fontWeight: FontWeight.w600,
|
|
|
|
|
),
|
|
|
|
|
),
|
|
|
|
|
centerTitle: true,
|
|
|
|
|
),
|
|
|
|
|
body: Center(
|
|
|
|
|
child: ImprovedEmptyState(
|
2025-08-23 20:09:43 +05:30
|
|
|
title: AppLocalizations.of(context)!.unableToLoadProfile,
|
|
|
|
|
subtitle: AppLocalizations.of(context)!.pleaseCheckConnection,
|
2025-08-10 01:20:45 +05:30
|
|
|
icon: UiUtils.platformIcon(
|
|
|
|
|
ios: CupertinoIcons.exclamationmark_triangle,
|
|
|
|
|
android: Icons.error_outline,
|
|
|
|
|
),
|
|
|
|
|
),
|
|
|
|
|
),
|
|
|
|
|
),
|
|
|
|
|
),
|
|
|
|
|
);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
Widget _buildProfileHeader(dynamic user) {
|
|
|
|
|
return Builder(
|
|
|
|
|
builder: (context) => ConduitCard(
|
|
|
|
|
padding: const EdgeInsets.all(Spacing.cardPadding),
|
|
|
|
|
child: Row(
|
|
|
|
|
children: [
|
|
|
|
|
// Enhanced avatar with better sizing and shadows
|
|
|
|
|
Container(
|
|
|
|
|
decoration: BoxDecoration(
|
|
|
|
|
borderRadius: BorderRadius.circular(AppBorderRadius.avatar),
|
|
|
|
|
boxShadow: ConduitShadows.card,
|
|
|
|
|
),
|
|
|
|
|
child: ConduitAvatar(
|
|
|
|
|
size: IconSize.avatar,
|
|
|
|
|
text: user?.name?.substring(0, 1) ?? 'U',
|
|
|
|
|
),
|
|
|
|
|
),
|
|
|
|
|
const SizedBox(width: Spacing.md),
|
|
|
|
|
Expanded(
|
|
|
|
|
child: Column(
|
|
|
|
|
crossAxisAlignment: CrossAxisAlignment.start,
|
|
|
|
|
children: [
|
|
|
|
|
Text(
|
|
|
|
|
user?.name ?? 'User',
|
|
|
|
|
style: context.conduitTheme.headingMedium?.copyWith(
|
|
|
|
|
color: context.conduitTheme.textPrimary,
|
|
|
|
|
fontWeight: FontWeight.w600,
|
|
|
|
|
),
|
|
|
|
|
),
|
2025-08-22 01:24:04 +05:30
|
|
|
const SizedBox(height: Spacing.sm),
|
2025-08-10 01:20:45 +05:30
|
|
|
Text(
|
|
|
|
|
user?.email ?? 'No email',
|
|
|
|
|
style: context.conduitTheme.bodyMedium?.copyWith(
|
|
|
|
|
color: context.conduitTheme.textSecondary,
|
|
|
|
|
),
|
|
|
|
|
),
|
2025-08-22 01:24:04 +05:30
|
|
|
// Status badge removed per design update
|
2025-08-10 01:20:45 +05:30
|
|
|
],
|
|
|
|
|
),
|
|
|
|
|
),
|
|
|
|
|
],
|
|
|
|
|
),
|
|
|
|
|
),
|
|
|
|
|
);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
Widget _buildAccountSection(BuildContext context, WidgetRef ref) {
|
|
|
|
|
return Column(
|
|
|
|
|
crossAxisAlignment: CrossAxisAlignment.start,
|
|
|
|
|
children: [
|
|
|
|
|
Text(
|
2025-08-23 20:09:43 +05:30
|
|
|
AppLocalizations.of(context)!.account,
|
2025-08-10 01:20:45 +05:30
|
|
|
style: context.conduitTheme.headingSmall?.copyWith(
|
|
|
|
|
color: context.conduitTheme.textPrimary,
|
|
|
|
|
),
|
|
|
|
|
),
|
|
|
|
|
const SizedBox(height: Spacing.md),
|
|
|
|
|
ConduitCard(
|
|
|
|
|
padding: EdgeInsets.zero,
|
|
|
|
|
child: Column(
|
|
|
|
|
children: [
|
2025-08-17 17:01:06 +05:30
|
|
|
_buildDefaultModelTile(context, ref),
|
|
|
|
|
Divider(color: context.conduitTheme.dividerColor, height: 1),
|
2025-08-10 01:20:45 +05:30
|
|
|
_buildThemeToggleTile(context, ref),
|
|
|
|
|
Divider(color: context.conduitTheme.dividerColor, height: 1),
|
2025-08-23 20:09:43 +05:30
|
|
|
_buildLanguageTile(context, ref),
|
|
|
|
|
Divider(color: context.conduitTheme.dividerColor, height: 1),
|
2025-08-10 01:20:45 +05:30
|
|
|
_buildAboutTile(context),
|
|
|
|
|
Divider(color: context.conduitTheme.dividerColor, height: 1),
|
|
|
|
|
_buildAccountOption(
|
|
|
|
|
icon: UiUtils.platformIcon(
|
|
|
|
|
ios: CupertinoIcons.square_arrow_left,
|
|
|
|
|
android: Icons.logout,
|
|
|
|
|
),
|
2025-08-23 20:09:43 +05:30
|
|
|
title: AppLocalizations.of(context)!.signOut,
|
|
|
|
|
subtitle: AppLocalizations.of(context)!.endYourSession,
|
2025-08-10 01:20:45 +05:30
|
|
|
onTap: () => _signOut(context, ref),
|
|
|
|
|
isDestructive: true,
|
|
|
|
|
),
|
|
|
|
|
],
|
|
|
|
|
),
|
|
|
|
|
),
|
|
|
|
|
],
|
|
|
|
|
);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
Widget _buildAccountOption({
|
|
|
|
|
required IconData icon,
|
|
|
|
|
required String title,
|
|
|
|
|
required String subtitle,
|
|
|
|
|
required VoidCallback onTap,
|
|
|
|
|
bool isDestructive = false,
|
|
|
|
|
}) {
|
|
|
|
|
return Builder(
|
|
|
|
|
builder: (context) => ListTile(
|
|
|
|
|
contentPadding: const EdgeInsets.symmetric(
|
|
|
|
|
horizontal: Spacing.listItemPadding,
|
|
|
|
|
vertical: Spacing.sm,
|
|
|
|
|
),
|
|
|
|
|
leading: Container(
|
|
|
|
|
padding: const EdgeInsets.all(Spacing.sm),
|
|
|
|
|
decoration: BoxDecoration(
|
|
|
|
|
color: isDestructive
|
|
|
|
|
? context.conduitTheme.error.withValues(alpha: Alpha.highlight)
|
|
|
|
|
: context.conduitTheme.buttonPrimary.withValues(
|
|
|
|
|
alpha: Alpha.highlight,
|
|
|
|
|
),
|
|
|
|
|
borderRadius: BorderRadius.circular(AppBorderRadius.small),
|
|
|
|
|
),
|
|
|
|
|
child: Icon(
|
|
|
|
|
icon,
|
|
|
|
|
color: isDestructive
|
|
|
|
|
? context.conduitTheme.error
|
|
|
|
|
: context.conduitTheme.buttonPrimary,
|
|
|
|
|
size: IconSize.medium,
|
|
|
|
|
),
|
|
|
|
|
),
|
|
|
|
|
title: Text(
|
|
|
|
|
title,
|
|
|
|
|
style: context.conduitTheme.bodyLarge?.copyWith(
|
|
|
|
|
color: isDestructive
|
|
|
|
|
? context.conduitTheme.error
|
|
|
|
|
: context.conduitTheme.textPrimary,
|
|
|
|
|
fontWeight: FontWeight.w500,
|
|
|
|
|
),
|
|
|
|
|
),
|
|
|
|
|
subtitle: Text(
|
|
|
|
|
subtitle,
|
|
|
|
|
style: context.conduitTheme.bodySmall?.copyWith(
|
|
|
|
|
color: context.conduitTheme.textSecondary,
|
|
|
|
|
),
|
|
|
|
|
),
|
|
|
|
|
trailing: Icon(
|
|
|
|
|
UiUtils.platformIcon(
|
|
|
|
|
ios: CupertinoIcons.chevron_right,
|
|
|
|
|
android: Icons.chevron_right,
|
|
|
|
|
),
|
|
|
|
|
color: context.conduitTheme.iconSecondary,
|
|
|
|
|
size: IconSize.small,
|
|
|
|
|
),
|
|
|
|
|
onTap: onTap,
|
|
|
|
|
),
|
|
|
|
|
);
|
|
|
|
|
}
|
|
|
|
|
|
2025-08-17 17:01:06 +05:30
|
|
|
Widget _buildDefaultModelTile(BuildContext context, WidgetRef ref) {
|
|
|
|
|
final settings = ref.watch(appSettingsProvider);
|
|
|
|
|
final modelsAsync = ref.watch(modelsProvider);
|
2025-08-24 20:27:11 +05:30
|
|
|
|
2025-08-17 17:01:06 +05:30
|
|
|
return modelsAsync.when(
|
|
|
|
|
data: (models) {
|
|
|
|
|
final currentModel = models.firstWhere(
|
|
|
|
|
(m) => m.id == settings.defaultModel,
|
2025-08-24 20:27:11 +05:30
|
|
|
orElse: () => models.isNotEmpty
|
|
|
|
|
? models.first
|
|
|
|
|
: const Model(id: 'none', name: 'No models available'),
|
2025-08-17 17:01:06 +05:30
|
|
|
);
|
2025-08-24 20:27:11 +05:30
|
|
|
|
2025-08-17 17:01:06 +05:30
|
|
|
return ListTile(
|
|
|
|
|
contentPadding: const EdgeInsets.symmetric(
|
|
|
|
|
horizontal: Spacing.listItemPadding,
|
|
|
|
|
vertical: Spacing.sm,
|
|
|
|
|
),
|
|
|
|
|
leading: Container(
|
|
|
|
|
padding: const EdgeInsets.all(Spacing.sm),
|
|
|
|
|
decoration: BoxDecoration(
|
|
|
|
|
color: context.conduitTheme.buttonPrimary.withValues(
|
|
|
|
|
alpha: Alpha.highlight,
|
|
|
|
|
),
|
|
|
|
|
borderRadius: BorderRadius.circular(AppBorderRadius.small),
|
|
|
|
|
),
|
|
|
|
|
child: Icon(
|
|
|
|
|
UiUtils.platformIcon(
|
|
|
|
|
ios: CupertinoIcons.cube_box,
|
|
|
|
|
android: Icons.psychology,
|
|
|
|
|
),
|
|
|
|
|
color: context.conduitTheme.buttonPrimary,
|
|
|
|
|
size: IconSize.medium,
|
|
|
|
|
),
|
|
|
|
|
),
|
|
|
|
|
title: Text(
|
2025-08-23 20:09:43 +05:30
|
|
|
AppLocalizations.of(context)!.defaultModel,
|
2025-08-17 17:01:06 +05:30
|
|
|
style: context.conduitTheme.bodyLarge?.copyWith(
|
|
|
|
|
color: context.conduitTheme.textPrimary,
|
|
|
|
|
fontWeight: FontWeight.w500,
|
|
|
|
|
),
|
|
|
|
|
),
|
|
|
|
|
subtitle: Text(
|
2025-08-24 20:27:11 +05:30
|
|
|
settings.defaultModel != null
|
|
|
|
|
? currentModel.name
|
|
|
|
|
: AppLocalizations.of(context)!.autoSelect,
|
2025-08-17 17:01:06 +05:30
|
|
|
style: context.conduitTheme.bodySmall?.copyWith(
|
|
|
|
|
color: context.conduitTheme.textSecondary,
|
|
|
|
|
),
|
|
|
|
|
),
|
|
|
|
|
trailing: Icon(
|
|
|
|
|
UiUtils.platformIcon(
|
|
|
|
|
ios: CupertinoIcons.chevron_right,
|
|
|
|
|
android: Icons.chevron_right,
|
|
|
|
|
),
|
|
|
|
|
color: context.conduitTheme.iconSecondary,
|
|
|
|
|
size: IconSize.small,
|
|
|
|
|
),
|
|
|
|
|
onTap: () => _showModelSelector(context, ref, models),
|
|
|
|
|
);
|
|
|
|
|
},
|
|
|
|
|
loading: () => ListTile(
|
|
|
|
|
contentPadding: const EdgeInsets.symmetric(
|
|
|
|
|
horizontal: Spacing.listItemPadding,
|
|
|
|
|
vertical: Spacing.sm,
|
|
|
|
|
),
|
|
|
|
|
leading: Container(
|
|
|
|
|
padding: const EdgeInsets.all(Spacing.sm),
|
|
|
|
|
decoration: BoxDecoration(
|
|
|
|
|
color: context.conduitTheme.buttonPrimary.withValues(
|
|
|
|
|
alpha: Alpha.highlight,
|
|
|
|
|
),
|
|
|
|
|
borderRadius: BorderRadius.circular(AppBorderRadius.small),
|
|
|
|
|
),
|
|
|
|
|
child: Icon(
|
|
|
|
|
UiUtils.platformIcon(
|
|
|
|
|
ios: CupertinoIcons.cube_box,
|
|
|
|
|
android: Icons.psychology,
|
|
|
|
|
),
|
|
|
|
|
color: context.conduitTheme.buttonPrimary,
|
|
|
|
|
size: IconSize.medium,
|
|
|
|
|
),
|
|
|
|
|
),
|
|
|
|
|
title: Text(
|
2025-08-23 20:09:43 +05:30
|
|
|
AppLocalizations.of(context)!.defaultModel,
|
2025-08-17 17:01:06 +05:30
|
|
|
style: context.conduitTheme.bodyLarge?.copyWith(
|
|
|
|
|
color: context.conduitTheme.textPrimary,
|
|
|
|
|
fontWeight: FontWeight.w500,
|
|
|
|
|
),
|
|
|
|
|
),
|
|
|
|
|
subtitle: Text(
|
2025-08-23 20:09:43 +05:30
|
|
|
AppLocalizations.of(context)!.loadingModels,
|
2025-08-17 17:01:06 +05:30
|
|
|
style: context.conduitTheme.bodySmall?.copyWith(
|
|
|
|
|
color: context.conduitTheme.textSecondary,
|
|
|
|
|
),
|
|
|
|
|
),
|
|
|
|
|
),
|
|
|
|
|
error: (error, stack) => ListTile(
|
|
|
|
|
contentPadding: const EdgeInsets.symmetric(
|
|
|
|
|
horizontal: Spacing.listItemPadding,
|
|
|
|
|
vertical: Spacing.sm,
|
|
|
|
|
),
|
|
|
|
|
leading: Container(
|
|
|
|
|
padding: const EdgeInsets.all(Spacing.sm),
|
|
|
|
|
decoration: BoxDecoration(
|
|
|
|
|
color: context.conduitTheme.error.withValues(
|
|
|
|
|
alpha: Alpha.highlight,
|
|
|
|
|
),
|
|
|
|
|
borderRadius: BorderRadius.circular(AppBorderRadius.small),
|
|
|
|
|
),
|
|
|
|
|
child: Icon(
|
|
|
|
|
UiUtils.platformIcon(
|
|
|
|
|
ios: CupertinoIcons.exclamationmark_triangle,
|
|
|
|
|
android: Icons.error_outline,
|
|
|
|
|
),
|
|
|
|
|
color: context.conduitTheme.error,
|
|
|
|
|
size: IconSize.medium,
|
|
|
|
|
),
|
|
|
|
|
),
|
|
|
|
|
title: Text(
|
2025-08-23 20:09:43 +05:30
|
|
|
AppLocalizations.of(context)!.defaultModel,
|
2025-08-17 17:01:06 +05:30
|
|
|
style: context.conduitTheme.bodyLarge?.copyWith(
|
|
|
|
|
color: context.conduitTheme.textPrimary,
|
|
|
|
|
fontWeight: FontWeight.w500,
|
|
|
|
|
),
|
|
|
|
|
),
|
|
|
|
|
subtitle: Text(
|
2025-08-23 20:09:43 +05:30
|
|
|
AppLocalizations.of(context)!.failedToLoadModels,
|
2025-08-17 17:01:06 +05:30
|
|
|
style: context.conduitTheme.bodySmall?.copyWith(
|
|
|
|
|
color: context.conduitTheme.error,
|
|
|
|
|
),
|
|
|
|
|
),
|
|
|
|
|
),
|
|
|
|
|
);
|
|
|
|
|
}
|
|
|
|
|
|
2025-08-23 20:09:43 +05:30
|
|
|
Widget _buildLanguageTile(BuildContext context, WidgetRef ref) {
|
|
|
|
|
final locale = ref.watch(localeProvider);
|
|
|
|
|
final currentCode = locale?.languageCode ?? 'system';
|
|
|
|
|
final label = () {
|
|
|
|
|
switch (currentCode) {
|
|
|
|
|
case 'en':
|
|
|
|
|
return 'English';
|
|
|
|
|
case 'de':
|
|
|
|
|
return 'Deutsch';
|
|
|
|
|
case 'fr':
|
|
|
|
|
return 'Français';
|
|
|
|
|
case 'it':
|
|
|
|
|
return 'Italiano';
|
|
|
|
|
default:
|
|
|
|
|
return 'System';
|
|
|
|
|
}
|
|
|
|
|
}();
|
|
|
|
|
|
|
|
|
|
return ListTile(
|
|
|
|
|
contentPadding: const EdgeInsets.symmetric(
|
|
|
|
|
horizontal: Spacing.listItemPadding,
|
|
|
|
|
vertical: Spacing.sm,
|
|
|
|
|
),
|
|
|
|
|
leading: Container(
|
|
|
|
|
padding: const EdgeInsets.all(Spacing.sm),
|
|
|
|
|
decoration: BoxDecoration(
|
|
|
|
|
color: context.conduitTheme.buttonPrimary.withValues(
|
|
|
|
|
alpha: Alpha.highlight,
|
|
|
|
|
),
|
|
|
|
|
borderRadius: BorderRadius.circular(AppBorderRadius.small),
|
|
|
|
|
),
|
|
|
|
|
child: Icon(
|
|
|
|
|
UiUtils.platformIcon(
|
|
|
|
|
ios: CupertinoIcons.globe,
|
|
|
|
|
android: Icons.language,
|
|
|
|
|
),
|
|
|
|
|
color: context.conduitTheme.buttonPrimary,
|
|
|
|
|
size: IconSize.medium,
|
|
|
|
|
),
|
|
|
|
|
),
|
|
|
|
|
title: Text(
|
2025-08-24 20:27:11 +05:30
|
|
|
AppLocalizations.of(context)!.appLanguage,
|
2025-08-23 20:09:43 +05:30
|
|
|
style: context.conduitTheme.bodyLarge?.copyWith(
|
|
|
|
|
color: context.conduitTheme.textPrimary,
|
|
|
|
|
fontWeight: FontWeight.w500,
|
|
|
|
|
),
|
|
|
|
|
),
|
|
|
|
|
subtitle: Text(
|
|
|
|
|
label,
|
|
|
|
|
style: context.conduitTheme.bodySmall?.copyWith(
|
|
|
|
|
color: context.conduitTheme.textSecondary,
|
|
|
|
|
),
|
|
|
|
|
),
|
|
|
|
|
trailing: Icon(
|
|
|
|
|
UiUtils.platformIcon(
|
|
|
|
|
ios: CupertinoIcons.chevron_right,
|
|
|
|
|
android: Icons.chevron_right,
|
|
|
|
|
),
|
|
|
|
|
color: context.conduitTheme.iconSecondary,
|
|
|
|
|
size: IconSize.small,
|
|
|
|
|
),
|
|
|
|
|
onTap: () async {
|
|
|
|
|
final selected = await _showLanguageSelector(context, currentCode);
|
|
|
|
|
if (selected != null) {
|
|
|
|
|
if (selected == 'system') {
|
|
|
|
|
await ref.read(localeProvider.notifier).setLocale(null);
|
|
|
|
|
} else {
|
|
|
|
|
await ref.read(localeProvider.notifier).setLocale(Locale(selected));
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
},
|
|
|
|
|
);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
Future<String?> _showLanguageSelector(BuildContext context, String current) {
|
|
|
|
|
return showModalBottomSheet<String>(
|
|
|
|
|
context: context,
|
|
|
|
|
backgroundColor: Colors.transparent,
|
|
|
|
|
isScrollControlled: true,
|
|
|
|
|
builder: (context) => Container(
|
|
|
|
|
decoration: BoxDecoration(
|
|
|
|
|
color: context.conduitTheme.surfaceBackground,
|
|
|
|
|
borderRadius: const BorderRadius.vertical(
|
|
|
|
|
top: Radius.circular(AppBorderRadius.modal),
|
|
|
|
|
),
|
|
|
|
|
boxShadow: ConduitShadows.modal,
|
|
|
|
|
),
|
|
|
|
|
child: SafeArea(
|
|
|
|
|
top: false,
|
|
|
|
|
child: Column(
|
|
|
|
|
mainAxisSize: MainAxisSize.min,
|
|
|
|
|
children: [
|
|
|
|
|
const SizedBox(height: Spacing.sm),
|
|
|
|
|
ListTile(
|
2025-08-23 23:56:53 +05:30
|
|
|
title: Text(AppLocalizations.of(context)!.system),
|
2025-08-23 20:09:43 +05:30
|
|
|
trailing: current == 'system' ? const Icon(Icons.check) : null,
|
|
|
|
|
onTap: () => Navigator.pop(context, 'system'),
|
|
|
|
|
),
|
|
|
|
|
ListTile(
|
2025-08-23 23:56:53 +05:30
|
|
|
title: Text(AppLocalizations.of(context)!.english),
|
2025-08-23 20:09:43 +05:30
|
|
|
trailing: current == 'en' ? const Icon(Icons.check) : null,
|
|
|
|
|
onTap: () => Navigator.pop(context, 'en'),
|
|
|
|
|
),
|
|
|
|
|
ListTile(
|
2025-08-23 23:56:53 +05:30
|
|
|
title: Text(AppLocalizations.of(context)!.deutsch),
|
2025-08-23 20:09:43 +05:30
|
|
|
trailing: current == 'de' ? const Icon(Icons.check) : null,
|
|
|
|
|
onTap: () => Navigator.pop(context, 'de'),
|
|
|
|
|
),
|
|
|
|
|
ListTile(
|
2025-08-23 23:56:53 +05:30
|
|
|
title: Text(AppLocalizations.of(context)!.francais),
|
2025-08-23 20:09:43 +05:30
|
|
|
trailing: current == 'fr' ? const Icon(Icons.check) : null,
|
|
|
|
|
onTap: () => Navigator.pop(context, 'fr'),
|
|
|
|
|
),
|
|
|
|
|
ListTile(
|
2025-08-23 23:56:53 +05:30
|
|
|
title: Text(AppLocalizations.of(context)!.italiano),
|
2025-08-23 20:09:43 +05:30
|
|
|
trailing: current == 'it' ? const Icon(Icons.check) : null,
|
|
|
|
|
onTap: () => Navigator.pop(context, 'it'),
|
|
|
|
|
),
|
|
|
|
|
const SizedBox(height: Spacing.sm),
|
|
|
|
|
],
|
|
|
|
|
),
|
|
|
|
|
),
|
|
|
|
|
),
|
|
|
|
|
);
|
|
|
|
|
}
|
|
|
|
|
|
2025-08-10 01:20:45 +05:30
|
|
|
Widget _buildThemeToggleTile(BuildContext context, WidgetRef ref) {
|
|
|
|
|
final themeMode = ref.watch(themeModeProvider);
|
2025-08-12 13:07:10 +05:30
|
|
|
final platformBrightness = MediaQuery.platformBrightnessOf(context);
|
|
|
|
|
final bool isDarkEffective =
|
|
|
|
|
themeMode == ThemeMode.dark ||
|
|
|
|
|
(themeMode == ThemeMode.system &&
|
|
|
|
|
platformBrightness == Brightness.dark);
|
2025-08-10 01:20:45 +05:30
|
|
|
|
|
|
|
|
return ListTile(
|
|
|
|
|
contentPadding: const EdgeInsets.symmetric(
|
|
|
|
|
horizontal: Spacing.listItemPadding,
|
|
|
|
|
vertical: Spacing.sm,
|
|
|
|
|
),
|
|
|
|
|
leading: Container(
|
|
|
|
|
padding: const EdgeInsets.all(Spacing.sm),
|
|
|
|
|
decoration: BoxDecoration(
|
|
|
|
|
color: context.conduitTheme.buttonPrimary.withValues(
|
|
|
|
|
alpha: Alpha.highlight,
|
|
|
|
|
),
|
|
|
|
|
borderRadius: BorderRadius.circular(AppBorderRadius.small),
|
|
|
|
|
),
|
|
|
|
|
child: Icon(
|
|
|
|
|
UiUtils.platformIcon(
|
|
|
|
|
ios: CupertinoIcons.moon_stars,
|
|
|
|
|
android: Icons.dark_mode,
|
|
|
|
|
),
|
|
|
|
|
color: context.conduitTheme.buttonPrimary,
|
|
|
|
|
size: IconSize.medium,
|
|
|
|
|
),
|
|
|
|
|
),
|
|
|
|
|
title: Text(
|
2025-08-24 20:27:11 +05:30
|
|
|
AppLocalizations.of(context)!.darkMode,
|
2025-08-10 01:20:45 +05:30
|
|
|
style: context.conduitTheme.bodyLarge?.copyWith(
|
|
|
|
|
color: context.conduitTheme.textPrimary,
|
|
|
|
|
fontWeight: FontWeight.w500,
|
|
|
|
|
),
|
|
|
|
|
),
|
|
|
|
|
subtitle: Text(
|
2025-08-12 13:07:10 +05:30
|
|
|
themeMode == ThemeMode.system
|
|
|
|
|
? 'Following system: '
|
|
|
|
|
'${platformBrightness == Brightness.dark ? 'Dark' : 'Light'}'
|
|
|
|
|
: (isDarkEffective
|
|
|
|
|
? 'Currently using Dark theme'
|
|
|
|
|
: 'Currently using Light theme'),
|
2025-08-10 01:20:45 +05:30
|
|
|
style: context.conduitTheme.bodySmall?.copyWith(
|
|
|
|
|
color: context.conduitTheme.textSecondary,
|
|
|
|
|
),
|
|
|
|
|
),
|
|
|
|
|
trailing: Switch.adaptive(
|
2025-08-12 13:07:10 +05:30
|
|
|
value: isDarkEffective,
|
2025-08-10 01:20:45 +05:30
|
|
|
onChanged: (value) {
|
|
|
|
|
ref
|
|
|
|
|
.read(themeModeProvider.notifier)
|
|
|
|
|
.setTheme(value ? ThemeMode.dark : ThemeMode.light);
|
|
|
|
|
},
|
|
|
|
|
),
|
|
|
|
|
onTap: () {
|
2025-08-12 13:07:10 +05:30
|
|
|
final newValue = !isDarkEffective;
|
2025-08-10 01:20:45 +05:30
|
|
|
ref
|
|
|
|
|
.read(themeModeProvider.notifier)
|
|
|
|
|
.setTheme(newValue ? ThemeMode.dark : ThemeMode.light);
|
|
|
|
|
},
|
|
|
|
|
);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
Widget _buildAboutTile(BuildContext context) {
|
|
|
|
|
return _buildAccountOption(
|
|
|
|
|
icon: UiUtils.platformIcon(
|
|
|
|
|
ios: CupertinoIcons.info,
|
|
|
|
|
android: Icons.info_outline,
|
|
|
|
|
),
|
2025-08-23 23:56:53 +05:30
|
|
|
title: AppLocalizations.of(context)!.aboutApp,
|
|
|
|
|
subtitle: AppLocalizations.of(context)!.aboutAppSubtitle,
|
2025-08-10 01:20:45 +05:30
|
|
|
onTap: () => _showAboutDialog(context),
|
|
|
|
|
);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
Future<void> _showAboutDialog(BuildContext context) async {
|
|
|
|
|
try {
|
|
|
|
|
final info = await PackageInfo.fromPlatform();
|
|
|
|
|
// Update dialog with dynamic version each time
|
|
|
|
|
// GitHub repo URL source of truth
|
|
|
|
|
const githubUrl = 'https://github.com/cogwheel0/conduit';
|
|
|
|
|
|
|
|
|
|
if (!context.mounted) return;
|
|
|
|
|
await showDialog<void>(
|
|
|
|
|
context: context,
|
|
|
|
|
builder: (ctx) {
|
|
|
|
|
return AlertDialog(
|
|
|
|
|
backgroundColor: ctx.conduitTheme.surfaceBackground,
|
|
|
|
|
title: Text(
|
|
|
|
|
'About Conduit',
|
|
|
|
|
style: ctx.conduitTheme.headingSmall?.copyWith(
|
|
|
|
|
color: ctx.conduitTheme.textPrimary,
|
|
|
|
|
),
|
|
|
|
|
),
|
|
|
|
|
content: Column(
|
|
|
|
|
mainAxisSize: MainAxisSize.min,
|
|
|
|
|
crossAxisAlignment: CrossAxisAlignment.start,
|
|
|
|
|
children: [
|
|
|
|
|
Text(
|
|
|
|
|
'Version: ${info.version} (${info.buildNumber})',
|
|
|
|
|
style: ctx.conduitTheme.bodyMedium?.copyWith(
|
|
|
|
|
color: ctx.conduitTheme.textSecondary,
|
|
|
|
|
),
|
|
|
|
|
),
|
|
|
|
|
const SizedBox(height: Spacing.md),
|
|
|
|
|
InkWell(
|
|
|
|
|
onTap: () => launchUrlString(
|
|
|
|
|
githubUrl,
|
|
|
|
|
mode: LaunchMode.externalApplication,
|
|
|
|
|
),
|
|
|
|
|
child: Row(
|
|
|
|
|
mainAxisSize: MainAxisSize.min,
|
|
|
|
|
children: [
|
|
|
|
|
Icon(
|
|
|
|
|
UiUtils.platformIcon(
|
|
|
|
|
ios: CupertinoIcons.link,
|
|
|
|
|
android: Icons.link,
|
|
|
|
|
),
|
|
|
|
|
size: IconSize.small,
|
|
|
|
|
color: ctx.conduitTheme.buttonPrimary,
|
|
|
|
|
),
|
|
|
|
|
const SizedBox(width: Spacing.xs),
|
|
|
|
|
Text(
|
|
|
|
|
'GitHub Repository',
|
|
|
|
|
style: ctx.conduitTheme.bodyMedium?.copyWith(
|
|
|
|
|
color: ctx.conduitTheme.buttonPrimary,
|
|
|
|
|
fontWeight: FontWeight.w600,
|
|
|
|
|
),
|
|
|
|
|
),
|
|
|
|
|
],
|
|
|
|
|
),
|
|
|
|
|
),
|
|
|
|
|
],
|
|
|
|
|
),
|
|
|
|
|
actions: [
|
|
|
|
|
TextButton(
|
|
|
|
|
onPressed: () => Navigator.of(ctx).pop(),
|
2025-08-23 20:09:43 +05:30
|
|
|
child: Text(AppLocalizations.of(ctx)!.closeButtonSemantic),
|
2025-08-10 01:20:45 +05:30
|
|
|
),
|
|
|
|
|
],
|
|
|
|
|
);
|
|
|
|
|
},
|
|
|
|
|
);
|
|
|
|
|
} catch (e) {
|
|
|
|
|
if (!context.mounted) return;
|
|
|
|
|
UiUtils.showMessage(context, 'Unable to load app info');
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
2025-08-24 20:27:11 +05:30
|
|
|
Future<void> _showModelSelector(
|
|
|
|
|
BuildContext context,
|
|
|
|
|
WidgetRef ref,
|
|
|
|
|
List<Model> models,
|
|
|
|
|
) async {
|
2025-08-17 17:01:06 +05:30
|
|
|
final result = await showModalBottomSheet<String?>(
|
|
|
|
|
context: context,
|
|
|
|
|
isScrollControlled: true,
|
|
|
|
|
backgroundColor: Colors.transparent,
|
|
|
|
|
builder: (ctx) => _DefaultModelBottomSheet(
|
|
|
|
|
models: models,
|
|
|
|
|
currentDefaultModelId: ref.read(appSettingsProvider).defaultModel,
|
|
|
|
|
),
|
|
|
|
|
);
|
2025-08-24 20:27:11 +05:30
|
|
|
|
2025-08-17 17:43:19 +05:30
|
|
|
// result is non-null only when Save button is pressed
|
|
|
|
|
// null means the sheet was dismissed without saving
|
|
|
|
|
if (result != null) {
|
|
|
|
|
// Handle special case: 'auto-select' should be stored as null
|
|
|
|
|
final modelIdToSave = result == 'auto-select' ? null : result;
|
2025-08-24 20:27:11 +05:30
|
|
|
await ref
|
|
|
|
|
.read(appSettingsProvider.notifier)
|
|
|
|
|
.setDefaultModel(modelIdToSave);
|
2025-08-17 17:01:06 +05:30
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
2025-08-10 01:20:45 +05:30
|
|
|
void _signOut(BuildContext context, WidgetRef ref) async {
|
|
|
|
|
final confirm = await UiUtils.showConfirmationDialog(
|
|
|
|
|
context,
|
2025-08-23 20:09:43 +05:30
|
|
|
title: AppLocalizations.of(context)!.signOut,
|
|
|
|
|
message: AppLocalizations.of(context)!.endYourSession,
|
|
|
|
|
confirmText: AppLocalizations.of(context)!.signOut,
|
2025-08-10 01:20:45 +05:30
|
|
|
isDestructive: true,
|
|
|
|
|
);
|
|
|
|
|
|
|
|
|
|
if (confirm) {
|
|
|
|
|
await ref.read(logoutActionProvider);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
2025-08-17 17:01:06 +05:30
|
|
|
|
|
|
|
|
class _DefaultModelBottomSheet extends ConsumerStatefulWidget {
|
|
|
|
|
final List<Model> models;
|
|
|
|
|
final String? currentDefaultModelId;
|
|
|
|
|
|
|
|
|
|
const _DefaultModelBottomSheet({
|
|
|
|
|
required this.models,
|
|
|
|
|
required this.currentDefaultModelId,
|
|
|
|
|
});
|
|
|
|
|
|
|
|
|
|
@override
|
2025-08-24 20:27:11 +05:30
|
|
|
ConsumerState<_DefaultModelBottomSheet> createState() =>
|
|
|
|
|
_DefaultModelBottomSheetState();
|
2025-08-17 17:01:06 +05:30
|
|
|
}
|
|
|
|
|
|
2025-08-24 20:27:11 +05:30
|
|
|
class _DefaultModelBottomSheetState
|
|
|
|
|
extends ConsumerState<_DefaultModelBottomSheet> {
|
2025-08-17 17:01:06 +05:30
|
|
|
final TextEditingController _searchController = TextEditingController();
|
|
|
|
|
String _searchQuery = '';
|
|
|
|
|
List<Model> _filteredModels = [];
|
|
|
|
|
Timer? _searchDebounce;
|
|
|
|
|
String? _selectedModelId;
|
|
|
|
|
|
|
|
|
|
Widget _capabilityChip({required IconData icon, required String label}) {
|
|
|
|
|
return Container(
|
|
|
|
|
margin: const EdgeInsets.only(right: Spacing.xs),
|
|
|
|
|
padding: const EdgeInsets.symmetric(horizontal: Spacing.xs, vertical: 2),
|
|
|
|
|
decoration: BoxDecoration(
|
|
|
|
|
color: context.conduitTheme.buttonPrimary.withValues(alpha: 0.08),
|
|
|
|
|
borderRadius: BorderRadius.circular(AppBorderRadius.chip),
|
|
|
|
|
border: Border.all(
|
|
|
|
|
color: context.conduitTheme.buttonPrimary.withValues(alpha: 0.3),
|
|
|
|
|
width: BorderWidth.thin,
|
|
|
|
|
),
|
|
|
|
|
),
|
|
|
|
|
child: Row(
|
|
|
|
|
mainAxisSize: MainAxisSize.min,
|
|
|
|
|
children: [
|
|
|
|
|
Icon(icon, size: 12, color: context.conduitTheme.buttonPrimary),
|
|
|
|
|
const SizedBox(width: 4),
|
|
|
|
|
Text(
|
|
|
|
|
label,
|
|
|
|
|
style: TextStyle(
|
|
|
|
|
fontSize: AppTypography.labelSmall,
|
|
|
|
|
color: context.conduitTheme.textSecondary,
|
|
|
|
|
fontWeight: FontWeight.w500,
|
|
|
|
|
),
|
|
|
|
|
),
|
|
|
|
|
],
|
|
|
|
|
),
|
|
|
|
|
);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
@override
|
|
|
|
|
void initState() {
|
|
|
|
|
super.initState();
|
2025-08-17 17:43:19 +05:30
|
|
|
// If no default model is set (null), default to auto-select
|
|
|
|
|
_selectedModelId = widget.currentDefaultModelId ?? 'auto-select';
|
2025-08-17 17:01:06 +05:30
|
|
|
// Add auto-select as first item
|
|
|
|
|
_filteredModels = [
|
|
|
|
|
const Model(id: 'auto-select', name: 'Auto-select'),
|
|
|
|
|
...widget.models,
|
|
|
|
|
];
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
@override
|
|
|
|
|
void dispose() {
|
|
|
|
|
_searchController.dispose();
|
|
|
|
|
_searchDebounce?.cancel();
|
|
|
|
|
super.dispose();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void _filterModels(String query) {
|
|
|
|
|
_searchDebounce?.cancel();
|
|
|
|
|
_searchDebounce = Timer(const Duration(milliseconds: 160), () {
|
|
|
|
|
setState(() {
|
|
|
|
|
_searchQuery = query.toLowerCase();
|
|
|
|
|
List<Model> allModels = [
|
|
|
|
|
const Model(id: 'auto-select', name: 'Auto-select'),
|
|
|
|
|
...widget.models,
|
|
|
|
|
];
|
2025-08-24 20:27:11 +05:30
|
|
|
|
2025-08-17 17:01:06 +05:30
|
|
|
if (_searchQuery.isNotEmpty) {
|
|
|
|
|
_filteredModels = allModels.where((model) {
|
|
|
|
|
return model.name.toLowerCase().contains(_searchQuery) ||
|
|
|
|
|
model.id.toLowerCase().contains(_searchQuery);
|
|
|
|
|
}).toList();
|
|
|
|
|
} else {
|
|
|
|
|
_filteredModels = allModels;
|
|
|
|
|
}
|
|
|
|
|
});
|
|
|
|
|
});
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
@override
|
|
|
|
|
Widget build(BuildContext context) {
|
|
|
|
|
return DraggableScrollableSheet(
|
|
|
|
|
initialChildSize: 0.75,
|
|
|
|
|
maxChildSize: 0.92,
|
|
|
|
|
minChildSize: 0.45,
|
|
|
|
|
builder: (context, scrollController) {
|
|
|
|
|
return Container(
|
|
|
|
|
decoration: BoxDecoration(
|
|
|
|
|
color: context.conduitTheme.surfaceBackground,
|
|
|
|
|
borderRadius: const BorderRadius.vertical(
|
|
|
|
|
top: Radius.circular(AppBorderRadius.bottomSheet),
|
|
|
|
|
),
|
|
|
|
|
border: Border.all(
|
|
|
|
|
color: context.conduitTheme.dividerColor,
|
|
|
|
|
width: BorderWidth.regular,
|
|
|
|
|
),
|
|
|
|
|
boxShadow: ConduitShadows.modal,
|
|
|
|
|
),
|
|
|
|
|
child: SafeArea(
|
|
|
|
|
top: false,
|
|
|
|
|
bottom: true,
|
|
|
|
|
child: Padding(
|
|
|
|
|
padding: const EdgeInsets.all(Spacing.bottomSheetPadding),
|
|
|
|
|
child: Column(
|
|
|
|
|
children: [
|
2025-08-22 01:24:04 +05:30
|
|
|
// Handle bar (standardized)
|
|
|
|
|
const SheetHandle(),
|
2025-08-17 17:01:06 +05:30
|
|
|
|
2025-08-22 01:24:04 +05:30
|
|
|
// Header removed (no icon/title or save button)
|
|
|
|
|
const SizedBox(height: Spacing.md),
|
2025-08-17 17:01:06 +05:30
|
|
|
|
|
|
|
|
// Search field
|
|
|
|
|
Padding(
|
|
|
|
|
padding: const EdgeInsets.only(bottom: Spacing.md),
|
|
|
|
|
child: TextField(
|
|
|
|
|
controller: _searchController,
|
|
|
|
|
style: TextStyle(color: context.conduitTheme.textPrimary),
|
|
|
|
|
decoration: InputDecoration(
|
2025-08-23 20:09:43 +05:30
|
|
|
hintText: AppLocalizations.of(context)!.searchModels,
|
2025-08-17 17:01:06 +05:30
|
|
|
hintStyle: TextStyle(
|
|
|
|
|
color: context.conduitTheme.inputPlaceholder,
|
|
|
|
|
),
|
|
|
|
|
prefixIcon: Icon(
|
|
|
|
|
Platform.isIOS ? CupertinoIcons.search : Icons.search,
|
|
|
|
|
color: context.conduitTheme.iconSecondary,
|
|
|
|
|
),
|
|
|
|
|
filled: true,
|
|
|
|
|
fillColor: context.conduitTheme.inputBackground,
|
|
|
|
|
border: OutlineInputBorder(
|
2025-08-24 20:27:11 +05:30
|
|
|
borderRadius: BorderRadius.circular(
|
|
|
|
|
AppBorderRadius.md,
|
|
|
|
|
),
|
2025-08-17 17:01:06 +05:30
|
|
|
borderSide: BorderSide.none,
|
|
|
|
|
),
|
|
|
|
|
enabledBorder: OutlineInputBorder(
|
2025-08-24 20:27:11 +05:30
|
|
|
borderRadius: BorderRadius.circular(
|
|
|
|
|
AppBorderRadius.md,
|
|
|
|
|
),
|
2025-08-17 17:01:06 +05:30
|
|
|
borderSide: BorderSide(
|
|
|
|
|
color: context.conduitTheme.inputBorder,
|
|
|
|
|
width: 1,
|
|
|
|
|
),
|
|
|
|
|
),
|
|
|
|
|
focusedBorder: OutlineInputBorder(
|
2025-08-24 20:27:11 +05:30
|
|
|
borderRadius: BorderRadius.circular(
|
|
|
|
|
AppBorderRadius.md,
|
|
|
|
|
),
|
2025-08-17 17:01:06 +05:30
|
|
|
borderSide: BorderSide(
|
|
|
|
|
color: context.conduitTheme.buttonPrimary,
|
|
|
|
|
width: 1,
|
|
|
|
|
),
|
|
|
|
|
),
|
|
|
|
|
contentPadding: const EdgeInsets.symmetric(
|
|
|
|
|
horizontal: Spacing.md,
|
|
|
|
|
vertical: Spacing.md,
|
|
|
|
|
),
|
|
|
|
|
),
|
|
|
|
|
onChanged: _filterModels,
|
|
|
|
|
),
|
|
|
|
|
),
|
|
|
|
|
|
2025-08-21 23:56:47 +05:30
|
|
|
// Section header (cohesive with Chats Drawer)
|
|
|
|
|
Padding(
|
|
|
|
|
padding: const EdgeInsets.only(bottom: Spacing.sm),
|
|
|
|
|
child: Row(
|
|
|
|
|
children: [
|
|
|
|
|
Text(
|
2025-08-23 20:09:43 +05:30
|
|
|
AppLocalizations.of(context)!.availableModels,
|
2025-08-21 23:56:47 +05:30
|
|
|
style: AppTypography.bodySmallStyle.copyWith(
|
|
|
|
|
fontWeight: FontWeight.w600,
|
|
|
|
|
color: context.conduitTheme.textSecondary,
|
|
|
|
|
letterSpacing: 0.2,
|
|
|
|
|
),
|
|
|
|
|
),
|
|
|
|
|
const SizedBox(width: Spacing.xs),
|
|
|
|
|
Container(
|
2025-08-24 20:27:11 +05:30
|
|
|
padding: const EdgeInsets.symmetric(
|
|
|
|
|
horizontal: 6,
|
|
|
|
|
vertical: 2,
|
|
|
|
|
),
|
2025-08-21 23:56:47 +05:30
|
|
|
decoration: BoxDecoration(
|
2025-08-24 20:27:11 +05:30
|
|
|
color: context.conduitTheme.surfaceBackground
|
|
|
|
|
.withValues(alpha: 0.6),
|
|
|
|
|
borderRadius: BorderRadius.circular(
|
|
|
|
|
AppBorderRadius.xs,
|
|
|
|
|
),
|
2025-08-21 23:56:47 +05:30
|
|
|
border: Border.all(
|
|
|
|
|
color: context.conduitTheme.dividerColor,
|
|
|
|
|
width: BorderWidth.thin,
|
|
|
|
|
),
|
|
|
|
|
),
|
|
|
|
|
child: Text(
|
|
|
|
|
'${_filteredModels.length}',
|
|
|
|
|
style: AppTypography.bodySmallStyle.copyWith(
|
|
|
|
|
color: context.conduitTheme.textSecondary,
|
|
|
|
|
),
|
|
|
|
|
),
|
|
|
|
|
),
|
|
|
|
|
],
|
|
|
|
|
),
|
|
|
|
|
),
|
|
|
|
|
|
2025-08-17 17:01:06 +05:30
|
|
|
const SizedBox(height: Spacing.sm),
|
|
|
|
|
|
|
|
|
|
// Models list
|
|
|
|
|
Expanded(
|
|
|
|
|
child: Scrollbar(
|
|
|
|
|
controller: scrollController,
|
|
|
|
|
child: _filteredModels.isEmpty
|
|
|
|
|
? Center(
|
|
|
|
|
child: Column(
|
|
|
|
|
mainAxisAlignment: MainAxisAlignment.center,
|
|
|
|
|
children: [
|
|
|
|
|
Icon(
|
|
|
|
|
Platform.isIOS
|
|
|
|
|
? CupertinoIcons.search_circle
|
|
|
|
|
: Icons.search_off,
|
|
|
|
|
size: 48,
|
|
|
|
|
color: context.conduitTheme.iconSecondary,
|
|
|
|
|
),
|
|
|
|
|
const SizedBox(height: Spacing.md),
|
|
|
|
|
Text(
|
2025-08-23 20:09:43 +05:30
|
|
|
AppLocalizations.of(context)!.noResults,
|
2025-08-17 17:01:06 +05:30
|
|
|
style: TextStyle(
|
|
|
|
|
color: context.conduitTheme.textSecondary,
|
|
|
|
|
fontSize: AppTypography.bodyLarge,
|
|
|
|
|
),
|
|
|
|
|
),
|
|
|
|
|
],
|
|
|
|
|
),
|
|
|
|
|
)
|
|
|
|
|
: ListView.builder(
|
|
|
|
|
controller: scrollController,
|
|
|
|
|
padding: EdgeInsets.zero,
|
|
|
|
|
itemCount: _filteredModels.length,
|
|
|
|
|
itemBuilder: (context, index) {
|
|
|
|
|
final model = _filteredModels[index];
|
|
|
|
|
final isAutoSelect = model.id == 'auto-select';
|
2025-08-24 20:27:11 +05:30
|
|
|
final isSelected = isAutoSelect
|
|
|
|
|
? _selectedModelId == null ||
|
|
|
|
|
_selectedModelId == 'auto-select'
|
2025-08-17 17:01:06 +05:30
|
|
|
: _selectedModelId == model.id;
|
|
|
|
|
|
|
|
|
|
return _buildModelListTile(
|
|
|
|
|
model: model,
|
|
|
|
|
isSelected: isSelected,
|
|
|
|
|
isAutoSelect: isAutoSelect,
|
|
|
|
|
onTap: () {
|
2025-08-22 01:24:04 +05:30
|
|
|
HapticFeedback.lightImpact();
|
2025-08-24 20:27:11 +05:30
|
|
|
final selectedId = isAutoSelect
|
|
|
|
|
? 'auto-select'
|
|
|
|
|
: model.id;
|
2025-08-22 01:24:04 +05:30
|
|
|
// Return selection immediately; caller handles persisting
|
|
|
|
|
Navigator.pop(context, selectedId);
|
2025-08-17 17:01:06 +05:30
|
|
|
},
|
|
|
|
|
);
|
|
|
|
|
},
|
|
|
|
|
),
|
|
|
|
|
),
|
|
|
|
|
),
|
|
|
|
|
],
|
|
|
|
|
),
|
|
|
|
|
),
|
|
|
|
|
),
|
|
|
|
|
);
|
|
|
|
|
},
|
|
|
|
|
);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
bool _modelSupportsReasoning(Model model) {
|
|
|
|
|
final params = model.supportedParameters ?? const [];
|
|
|
|
|
return params.any((p) => p.toLowerCase().contains('reasoning'));
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
Widget _buildModelListTile({
|
|
|
|
|
required Model model,
|
|
|
|
|
required bool isSelected,
|
|
|
|
|
required bool isAutoSelect,
|
|
|
|
|
required VoidCallback onTap,
|
|
|
|
|
}) {
|
|
|
|
|
return PressableScale(
|
|
|
|
|
onTap: onTap,
|
|
|
|
|
borderRadius: BorderRadius.circular(AppBorderRadius.md),
|
|
|
|
|
child: Container(
|
|
|
|
|
margin: const EdgeInsets.only(bottom: Spacing.md),
|
|
|
|
|
decoration: BoxDecoration(
|
|
|
|
|
gradient: isSelected
|
|
|
|
|
? LinearGradient(
|
|
|
|
|
colors: [
|
|
|
|
|
context.conduitTheme.buttonPrimary.withValues(alpha: 0.2),
|
|
|
|
|
context.conduitTheme.buttonPrimary.withValues(alpha: 0.1),
|
|
|
|
|
],
|
|
|
|
|
)
|
|
|
|
|
: null,
|
|
|
|
|
color: isSelected
|
|
|
|
|
? null
|
|
|
|
|
: context.conduitTheme.surfaceBackground.withValues(alpha: 0.05),
|
|
|
|
|
borderRadius: BorderRadius.circular(AppBorderRadius.md),
|
|
|
|
|
border: Border.all(
|
|
|
|
|
color: isSelected
|
|
|
|
|
? context.conduitTheme.buttonPrimary.withValues(alpha: 0.5)
|
|
|
|
|
: context.conduitTheme.dividerColor,
|
|
|
|
|
width: BorderWidth.regular,
|
|
|
|
|
),
|
|
|
|
|
boxShadow: isSelected ? ConduitShadows.card : null,
|
|
|
|
|
),
|
|
|
|
|
child: Padding(
|
|
|
|
|
padding: const EdgeInsets.symmetric(
|
|
|
|
|
horizontal: Spacing.md,
|
|
|
|
|
vertical: Spacing.sm,
|
|
|
|
|
),
|
|
|
|
|
child: Row(
|
|
|
|
|
children: [
|
|
|
|
|
Container(
|
|
|
|
|
width: 32,
|
|
|
|
|
height: 32,
|
|
|
|
|
decoration: BoxDecoration(
|
2025-08-24 20:27:11 +05:30
|
|
|
color: context.conduitTheme.buttonPrimary.withValues(
|
|
|
|
|
alpha: 0.15,
|
|
|
|
|
),
|
2025-08-17 17:01:06 +05:30
|
|
|
borderRadius: BorderRadius.circular(AppBorderRadius.md),
|
|
|
|
|
),
|
|
|
|
|
child: Icon(
|
2025-08-24 20:27:11 +05:30
|
|
|
isAutoSelect
|
|
|
|
|
? (Platform.isIOS
|
|
|
|
|
? CupertinoIcons.wand_stars
|
|
|
|
|
: Icons.auto_awesome)
|
|
|
|
|
: (Platform.isIOS
|
|
|
|
|
? CupertinoIcons.cube
|
|
|
|
|
: Icons.psychology),
|
2025-08-17 17:01:06 +05:30
|
|
|
color: context.conduitTheme.buttonPrimary,
|
|
|
|
|
size: 16,
|
|
|
|
|
),
|
|
|
|
|
),
|
|
|
|
|
const SizedBox(width: Spacing.md),
|
|
|
|
|
Expanded(
|
|
|
|
|
child: Column(
|
|
|
|
|
crossAxisAlignment: CrossAxisAlignment.start,
|
|
|
|
|
children: [
|
|
|
|
|
Text(
|
2025-08-24 20:27:11 +05:30
|
|
|
isAutoSelect
|
|
|
|
|
? AppLocalizations.of(context)!.autoSelect
|
|
|
|
|
: model.name,
|
2025-08-17 17:01:06 +05:30
|
|
|
style: TextStyle(
|
|
|
|
|
color: context.conduitTheme.textPrimary,
|
|
|
|
|
fontWeight: FontWeight.w600,
|
|
|
|
|
fontSize: AppTypography.bodyMedium,
|
|
|
|
|
),
|
|
|
|
|
maxLines: 1,
|
|
|
|
|
overflow: TextOverflow.ellipsis,
|
|
|
|
|
),
|
|
|
|
|
if (isAutoSelect) ...[
|
|
|
|
|
const SizedBox(height: Spacing.xs),
|
|
|
|
|
Text(
|
|
|
|
|
'Let the app choose the best model',
|
|
|
|
|
style: TextStyle(
|
|
|
|
|
fontSize: AppTypography.bodySmall,
|
|
|
|
|
color: context.conduitTheme.textSecondary,
|
|
|
|
|
fontWeight: FontWeight.w400,
|
|
|
|
|
),
|
|
|
|
|
),
|
|
|
|
|
] else ...[
|
|
|
|
|
const SizedBox(height: Spacing.xs),
|
|
|
|
|
Row(
|
|
|
|
|
children: [
|
|
|
|
|
if (model.isMultimodal)
|
|
|
|
|
_capabilityChip(
|
|
|
|
|
icon: Platform.isIOS
|
|
|
|
|
? CupertinoIcons.photo
|
|
|
|
|
: Icons.image,
|
|
|
|
|
label: 'Multimodal',
|
|
|
|
|
),
|
|
|
|
|
if (_modelSupportsReasoning(model))
|
|
|
|
|
_capabilityChip(
|
|
|
|
|
icon: Platform.isIOS
|
|
|
|
|
? CupertinoIcons.lightbulb
|
|
|
|
|
: Icons.psychology_alt,
|
|
|
|
|
label: 'Reasoning',
|
|
|
|
|
),
|
|
|
|
|
],
|
|
|
|
|
),
|
|
|
|
|
],
|
|
|
|
|
],
|
|
|
|
|
),
|
|
|
|
|
),
|
|
|
|
|
const SizedBox(width: Spacing.md),
|
|
|
|
|
AnimatedOpacity(
|
|
|
|
|
opacity: isSelected ? 1 : 0.6,
|
|
|
|
|
duration: AnimationDuration.fast,
|
|
|
|
|
child: Container(
|
|
|
|
|
padding: const EdgeInsets.all(Spacing.xxs),
|
|
|
|
|
decoration: BoxDecoration(
|
|
|
|
|
color: isSelected
|
|
|
|
|
? context.conduitTheme.buttonPrimary
|
|
|
|
|
: context.conduitTheme.surfaceBackground,
|
|
|
|
|
borderRadius: BorderRadius.circular(AppBorderRadius.md),
|
|
|
|
|
border: Border.all(
|
|
|
|
|
color: isSelected
|
2025-08-24 20:27:11 +05:30
|
|
|
? context.conduitTheme.buttonPrimary.withValues(
|
|
|
|
|
alpha: 0.6,
|
|
|
|
|
)
|
2025-08-17 17:01:06 +05:30
|
|
|
: context.conduitTheme.dividerColor,
|
|
|
|
|
),
|
|
|
|
|
),
|
|
|
|
|
child: Icon(
|
|
|
|
|
isSelected
|
2025-08-24 20:27:11 +05:30
|
|
|
? (Platform.isIOS
|
|
|
|
|
? CupertinoIcons.check_mark
|
|
|
|
|
: Icons.check)
|
2025-08-17 17:01:06 +05:30
|
|
|
: (Platform.isIOS ? CupertinoIcons.add : Icons.add),
|
|
|
|
|
color: isSelected
|
|
|
|
|
? context.conduitTheme.textInverse
|
|
|
|
|
: context.conduitTheme.iconSecondary,
|
|
|
|
|
size: 14,
|
|
|
|
|
),
|
|
|
|
|
),
|
|
|
|
|
),
|
|
|
|
|
],
|
|
|
|
|
),
|
|
|
|
|
),
|
|
|
|
|
),
|
|
|
|
|
).animate().fadeIn(duration: AnimationDuration.microInteraction);
|
|
|
|
|
}
|
|
|
|
|
}
|