refactor: formatting
This commit is contained in:
@@ -15,7 +15,9 @@ class TokenValidator {
|
||||
}
|
||||
|
||||
// Check if it's an API key format (starts with sk- or similar)
|
||||
if (token.startsWith('sk-') || token.startsWith('api-') || token.startsWith('key-')) {
|
||||
if (token.startsWith('sk-') ||
|
||||
token.startsWith('api-') ||
|
||||
token.startsWith('key-')) {
|
||||
// API key format - validate differently
|
||||
if (token.length < 20) {
|
||||
return TokenValidationResult.invalid('API key too short');
|
||||
|
||||
@@ -24,14 +24,20 @@ sealed class Folder with _$Folder {
|
||||
final chats = items?['chats'] as List?;
|
||||
|
||||
// Handle both string IDs and conversation objects
|
||||
final conversationIds = chats?.map((chat) {
|
||||
final conversationIds =
|
||||
chats
|
||||
?.map((chat) {
|
||||
if (chat is String) {
|
||||
return chat;
|
||||
} else if (chat is Map<String, dynamic>) {
|
||||
return chat['id'] as String? ?? '';
|
||||
}
|
||||
return '';
|
||||
}).where((id) => id.isNotEmpty).toList().cast<String>() ?? <String>[];
|
||||
})
|
||||
.where((id) => id.isNotEmpty)
|
||||
.toList()
|
||||
.cast<String>() ??
|
||||
<String>[];
|
||||
|
||||
// Handle Unix timestamp conversion
|
||||
DateTime? parseTimestamp(dynamic timestamp) {
|
||||
|
||||
@@ -65,7 +65,6 @@ class InputValidationService {
|
||||
if (_isIPAddress(uri.host) && !_isValidIPAddress(uri.host)) {
|
||||
return 'Invalid IP address format (use 192.168.1.10)';
|
||||
}
|
||||
|
||||
} catch (e) {
|
||||
return 'Invalid server address format';
|
||||
}
|
||||
|
||||
@@ -16,7 +16,9 @@ class OptimizedStorageService {
|
||||
required FlutterSecureStorage secureStorage,
|
||||
required SharedPreferences prefs,
|
||||
}) : _prefs = prefs,
|
||||
_secureCredentialStorage = SecureCredentialStorage(instance: secureStorage);
|
||||
_secureCredentialStorage = SecureCredentialStorage(
|
||||
instance: secureStorage,
|
||||
);
|
||||
|
||||
// Optimized key names with versioning
|
||||
static const String _authTokenKey = 'auth_token_v3';
|
||||
|
||||
@@ -74,7 +74,9 @@ class PersistentStreamingService with WidgetsBindingObserver {
|
||||
|
||||
_connectivitySubscription?.cancel();
|
||||
_connectivityService = service;
|
||||
_connectivitySubscription = service.isConnected.listen(_handleConnectivityChange);
|
||||
_connectivitySubscription = service.isConnected.listen(
|
||||
_handleConnectivityChange,
|
||||
);
|
||||
}
|
||||
|
||||
void _handleConnectivityChange(bool connected) {
|
||||
|
||||
@@ -336,10 +336,12 @@ class PlatformService {
|
||||
// on Android 15+. Only control icon brightness; colors come from theme + EdgeToEdge.
|
||||
SystemChrome.setSystemUIOverlayStyle(
|
||||
SystemUiOverlayStyle(
|
||||
statusBarIconBrightness:
|
||||
isDarkContent ? Brightness.dark : Brightness.light,
|
||||
systemNavigationBarIconBrightness:
|
||||
isDarkContent ? Brightness.dark : Brightness.light,
|
||||
statusBarIconBrightness: isDarkContent
|
||||
? Brightness.dark
|
||||
: Brightness.light,
|
||||
systemNavigationBarIconBrightness: isDarkContent
|
||||
? Brightness.dark
|
||||
: Brightness.light,
|
||||
// Do NOT set status/navigation bar colors on Android.
|
||||
),
|
||||
);
|
||||
|
||||
@@ -9,7 +9,9 @@ class SecureCredentialStorage {
|
||||
late final FlutterSecureStorage _secureStorage;
|
||||
|
||||
SecureCredentialStorage({FlutterSecureStorage? instance}) {
|
||||
_secureStorage = instance ?? FlutterSecureStorage(
|
||||
_secureStorage =
|
||||
instance ??
|
||||
FlutterSecureStorage(
|
||||
aOptions: _getAndroidOptions(),
|
||||
iOptions: _getIOSOptions(),
|
||||
);
|
||||
|
||||
@@ -16,7 +16,9 @@ class StorageService {
|
||||
required SharedPreferences prefs,
|
||||
}) : _secureStorage = secureStorage,
|
||||
_prefs = prefs,
|
||||
_secureCredentialStorage = SecureCredentialStorage(instance: secureStorage);
|
||||
_secureCredentialStorage = SecureCredentialStorage(
|
||||
instance: secureStorage,
|
||||
);
|
||||
|
||||
// Secure storage keys
|
||||
static const String _authTokenKey = 'auth_token';
|
||||
|
||||
@@ -80,4 +80,3 @@ class InactivityWatchdog {
|
||||
} catch (_) {}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -70,7 +70,8 @@ class ReviewerModeService {
|
||||
}
|
||||
|
||||
// Get responses for category
|
||||
final responses = _cannedResponses[category] ?? _cannedResponses['general']!;
|
||||
final responses =
|
||||
_cannedResponses[category] ?? _cannedResponses['general']!;
|
||||
final response = responses[_random.nextInt(responses.length)];
|
||||
|
||||
// Replace placeholders
|
||||
|
||||
@@ -65,4 +65,3 @@ class _PressableScaleState extends State<PressableScale>
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -3,13 +3,7 @@ import 'package:freezed_annotation/freezed_annotation.dart';
|
||||
part 'outbound_task.freezed.dart';
|
||||
part 'outbound_task.g.dart';
|
||||
|
||||
enum TaskStatus {
|
||||
queued,
|
||||
running,
|
||||
succeeded,
|
||||
failed,
|
||||
cancelled,
|
||||
}
|
||||
enum TaskStatus { queued, running, succeeded, failed, cancelled }
|
||||
|
||||
@freezed
|
||||
abstract class OutboundTask with _$OutboundTask {
|
||||
@@ -74,7 +68,6 @@ abstract class OutboundTask with _$OutboundTask {
|
||||
String? error,
|
||||
}) = GenerateImageTask;
|
||||
|
||||
|
||||
const factory OutboundTask.generateTitle({
|
||||
required String id,
|
||||
required String conversationId,
|
||||
|
||||
@@ -751,10 +751,6 @@ class ConduitThemeExtension extends ThemeExtension<ConduitThemeExtension> {
|
||||
fontFamily: AppTypography.monospaceFontFamily,
|
||||
),
|
||||
);
|
||||
|
||||
|
||||
|
||||
|
||||
}
|
||||
|
||||
/// Extension method to easily access Conduit theme from BuildContext
|
||||
|
||||
@@ -31,7 +31,8 @@ class _ChatActionButtonState extends ConsumerState<ChatActionButton> {
|
||||
Widget build(BuildContext context) {
|
||||
final theme = context.conduitTheme;
|
||||
final hapticEnabled = ref.read(hapticEnabledProvider);
|
||||
final radius = widget.borderRadius ?? BorderRadius.circular(AppBorderRadius.lg);
|
||||
final radius =
|
||||
widget.borderRadius ?? BorderRadius.circular(AppBorderRadius.lg);
|
||||
final overlay = theme.buttonPrimary.withValues(alpha: 0.08);
|
||||
|
||||
return Tooltip(
|
||||
@@ -100,4 +101,3 @@ class _ChatActionButtonState extends ConsumerState<ChatActionButton> {
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -101,7 +101,8 @@ class ConduitButton extends ConsumerWidget {
|
||||
),
|
||||
child: isLoading
|
||||
? Semantics(
|
||||
label: AppLocalizations.of(context)?.loadingContent ?? 'Loading',
|
||||
label:
|
||||
AppLocalizations.of(context)?.loadingContent ?? 'Loading',
|
||||
excludeSemantics: true,
|
||||
child: SizedBox(
|
||||
width: IconSize.small,
|
||||
@@ -206,7 +207,10 @@ class ConduitInput extends StatelessWidget {
|
||||
SizedBox(height: Spacing.sm),
|
||||
],
|
||||
Semantics(
|
||||
label: semanticLabel ?? label ?? (AppLocalizations.of(context)?.inputField ?? 'Input field'),
|
||||
label:
|
||||
semanticLabel ??
|
||||
label ??
|
||||
(AppLocalizations.of(context)?.inputField ?? 'Input field'),
|
||||
textField: true,
|
||||
child: TextField(
|
||||
controller: controller,
|
||||
@@ -784,7 +788,10 @@ class AccessibleFormField extends StatelessWidget {
|
||||
SizedBox(height: isCompact ? Spacing.xs : Spacing.sm),
|
||||
],
|
||||
Semantics(
|
||||
label: semanticLabel ?? label ?? (AppLocalizations.of(context)?.inputField ?? 'Input field'),
|
||||
label:
|
||||
semanticLabel ??
|
||||
label ??
|
||||
(AppLocalizations.of(context)?.inputField ?? 'Input field'),
|
||||
textField: true,
|
||||
child: TextFormField(
|
||||
controller: controller,
|
||||
|
||||
@@ -348,8 +348,13 @@ class LoadingStateWrapper<T> extends StatelessWidget {
|
||||
return asyncValue.when(
|
||||
data: builder,
|
||||
loading: () => showLoadingOverlay
|
||||
? ConduitLoading.overlay(message: AppLocalizations.of(context)!.loadingContent)
|
||||
: loadingWidget ?? ConduitLoading.primary(message: AppLocalizations.of(context)!.loadingContent),
|
||||
? ConduitLoading.overlay(
|
||||
message: AppLocalizations.of(context)!.loadingContent,
|
||||
)
|
||||
: loadingWidget ??
|
||||
ConduitLoading.primary(
|
||||
message: AppLocalizations.of(context)!.loadingContent,
|
||||
),
|
||||
error: (error, stackTrace) {
|
||||
if (errorBuilder != null) {
|
||||
return errorBuilder!(error, stackTrace);
|
||||
|
||||
@@ -155,7 +155,11 @@ class ConduitMarkdownConfig {
|
||||
);
|
||||
}
|
||||
|
||||
static Widget _buildBase64Image(String dataUrl, BuildContext context, ConduitThemeExtension theme) {
|
||||
static Widget _buildBase64Image(
|
||||
String dataUrl,
|
||||
BuildContext context,
|
||||
ConduitThemeExtension theme,
|
||||
) {
|
||||
try {
|
||||
// Extract base64 part from data URL
|
||||
final commaIndex = dataUrl.indexOf(',');
|
||||
|
||||
@@ -20,7 +20,8 @@ class StreamingMarkdownWidget extends StatefulWidget {
|
||||
});
|
||||
|
||||
@override
|
||||
State<StreamingMarkdownWidget> createState() => _StreamingMarkdownWidgetState();
|
||||
State<StreamingMarkdownWidget> createState() =>
|
||||
_StreamingMarkdownWidgetState();
|
||||
}
|
||||
|
||||
class _StreamingMarkdownWidgetState extends State<StreamingMarkdownWidget> {
|
||||
@@ -182,9 +183,7 @@ class MarkdownWithLoading extends StatelessWidget {
|
||||
if (isLoading && (content == null || content!.isEmpty)) {
|
||||
return Container(
|
||||
padding: padding ?? const EdgeInsets.all(16),
|
||||
child: const Center(
|
||||
child: CircularProgressIndicator(),
|
||||
),
|
||||
child: const Center(child: CircularProgressIndicator()),
|
||||
);
|
||||
}
|
||||
|
||||
|
||||
@@ -22,8 +22,9 @@ class MiddleEllipsisText extends StatelessWidget {
|
||||
Widget build(BuildContext context) {
|
||||
return LayoutBuilder(
|
||||
builder: (context, constraints) {
|
||||
final TextStyle effectiveStyle =
|
||||
DefaultTextStyle.of(context).style.merge(style);
|
||||
final TextStyle effectiveStyle = DefaultTextStyle.of(
|
||||
context,
|
||||
).style.merge(style);
|
||||
final TextDirection direction = Directionality.of(context);
|
||||
final double maxWidth = constraints.maxWidth;
|
||||
|
||||
@@ -74,8 +75,10 @@ class MiddleEllipsisText extends StatelessWidget {
|
||||
? ''
|
||||
: text.substring(text.length - rightCount);
|
||||
|
||||
final trialSpan =
|
||||
TextSpan(text: '$start$ellipsis$end', style: effectiveStyle);
|
||||
final trialSpan = TextSpan(
|
||||
text: '$start$ellipsis$end',
|
||||
style: effectiveStyle,
|
||||
);
|
||||
final trialPainter = TextPainter(
|
||||
text: trialSpan,
|
||||
textDirection: direction,
|
||||
@@ -116,4 +119,3 @@ class MiddleEllipsisText extends StatelessWidget {
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -130,7 +130,9 @@ class _OptimizedListState<T> extends ConsumerState<OptimizedList<T>> {
|
||||
return widget.emptyWidget ??
|
||||
ImprovedEmptyState(
|
||||
title: AppLocalizations.of(context)!.noItems,
|
||||
subtitle: widget.emptyMessage ?? AppLocalizations.of(context)!.noItemsToDisplay,
|
||||
subtitle:
|
||||
widget.emptyMessage ??
|
||||
AppLocalizations.of(context)!.noItemsToDisplay,
|
||||
icon: Icons.inbox_outlined,
|
||||
);
|
||||
}
|
||||
@@ -138,7 +140,8 @@ class _OptimizedListState<T> extends ConsumerState<OptimizedList<T>> {
|
||||
// Build the list
|
||||
Widget listWidget;
|
||||
|
||||
final ScrollPhysics effectivePhysics = widget.physics ??
|
||||
final ScrollPhysics effectivePhysics =
|
||||
widget.physics ??
|
||||
(widget.onRefresh != null
|
||||
? const AlwaysScrollableScrollPhysics()
|
||||
: const ClampingScrollPhysics());
|
||||
@@ -276,14 +279,16 @@ class OptimizedSliverList<T> extends ConsumerWidget {
|
||||
return SliverToBoxAdapter(
|
||||
child:
|
||||
emptyWidget ??
|
||||
Builder(builder: (context) {
|
||||
Builder(
|
||||
builder: (context) {
|
||||
final l10n = AppLocalizations.of(context)!;
|
||||
return ImprovedEmptyState(
|
||||
title: l10n.noItems,
|
||||
subtitle: emptyMessage ?? l10n.noItemsToDisplay,
|
||||
icon: Icons.inbox_outlined,
|
||||
);
|
||||
}),
|
||||
},
|
||||
),
|
||||
);
|
||||
}
|
||||
|
||||
|
||||
@@ -9,15 +9,18 @@ class SheetHandle extends StatelessWidget {
|
||||
Widget build(BuildContext context) {
|
||||
return Center(
|
||||
child: Container(
|
||||
margin: margin ?? const EdgeInsets.only(top: Spacing.sm, bottom: Spacing.md),
|
||||
margin:
|
||||
margin ??
|
||||
const EdgeInsets.only(top: Spacing.sm, bottom: Spacing.md),
|
||||
width: 40,
|
||||
height: 4,
|
||||
decoration: BoxDecoration(
|
||||
color: context.conduitTheme.textPrimary.withValues(alpha: Alpha.medium),
|
||||
color: context.conduitTheme.textPrimary.withValues(
|
||||
alpha: Alpha.medium,
|
||||
),
|
||||
borderRadius: BorderRadius.circular(AppBorderRadius.xs),
|
||||
),
|
||||
),
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -145,8 +145,10 @@ class ThemedDialogs {
|
||||
),
|
||||
focusedBorder: OutlineInputBorder(
|
||||
borderRadius: BorderRadius.circular(AppBorderRadius.md),
|
||||
borderSide:
|
||||
BorderSide(color: theme.buttonPrimary, width: 1),
|
||||
borderSide: BorderSide(
|
||||
color: theme.buttonPrimary,
|
||||
width: 1,
|
||||
),
|
||||
),
|
||||
contentPadding: const EdgeInsets.symmetric(
|
||||
horizontal: Spacing.md,
|
||||
@@ -155,8 +157,8 @@ class ThemedDialogs {
|
||||
),
|
||||
onSubmitted: (v) {
|
||||
final trimmed = v.trim();
|
||||
final unchanged = (initialValue != null &&
|
||||
trimmed == initialValue.trim());
|
||||
final unchanged =
|
||||
(initialValue != null && trimmed == initialValue.trim());
|
||||
if (trimmed.isEmpty || unchanged) return;
|
||||
Navigator.of(ctx).pop(trimmed);
|
||||
},
|
||||
|
||||
@@ -56,12 +56,16 @@ Future<void> main(List<String> args) async {
|
||||
if (trPh == null) {
|
||||
// If string exists but no meta placeholders, warn only.
|
||||
if (keys.contains(k) && basePh.isNotEmpty) {
|
||||
warnings.add('[${f.path}] Key "$k" missing @meta placeholders; base has ${basePh.toList()..sort()}');
|
||||
warnings.add(
|
||||
'[${f.path}] Key "$k" missing @meta placeholders; base has ${basePh.toList()..sort()}',
|
||||
);
|
||||
}
|
||||
continue;
|
||||
}
|
||||
if (basePh.length != trPh.length || !basePh.containsAll(trPh)) {
|
||||
warnings.add('[${f.path}] Placeholder mismatch for "$k": expected ${basePh.toList()..sort()}, got ${trPh.toList()..sort()}');
|
||||
warnings.add(
|
||||
'[${f.path}] Placeholder mismatch for "$k": expected ${basePh.toList()..sort()}, got ${trPh.toList()..sort()}',
|
||||
);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -96,9 +100,7 @@ Map<String, dynamic> _readJson(File f) {
|
||||
}
|
||||
|
||||
Set<String> _nonMetaKeys(Map<String, dynamic> m) {
|
||||
return m.keys
|
||||
.where((k) => !k.startsWith('@') && k != '@@locale')
|
||||
.toSet();
|
||||
return m.keys.where((k) => !k.startsWith('@') && k != '@@locale').toSet();
|
||||
}
|
||||
|
||||
Map<String, Set<String>> _placeholdersMap(Map<String, dynamic> m) {
|
||||
|
||||
@@ -42,7 +42,9 @@ Future<void> main() async {
|
||||
}
|
||||
|
||||
if (missingMeta.isEmpty && missingDescription.isEmpty) {
|
||||
stdout.writeln('ARB descriptions check passed: all keys have @meta.description.');
|
||||
stdout.writeln(
|
||||
'ARB descriptions check passed: all keys have @meta.description.',
|
||||
);
|
||||
return;
|
||||
}
|
||||
|
||||
@@ -53,11 +55,12 @@ Future<void> main() async {
|
||||
}
|
||||
}
|
||||
if (missingDescription.isNotEmpty) {
|
||||
stderr.writeln('Missing description in @meta for keys (${missingDescription.length}):');
|
||||
stderr.writeln(
|
||||
'Missing description in @meta for keys (${missingDescription.length}):',
|
||||
);
|
||||
for (final k in missingDescription) {
|
||||
stderr.writeln(' - $k');
|
||||
}
|
||||
}
|
||||
exit(1);
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user