Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commit0b72c81

Browse files
committed
fix(auth): prevent multiple auth submissions with loading indicator
- Add _isProcessingAuth flag to track authentication processing state- Disable button and show CircularProgressIndicator during auth submission- Prevent multiple clicks by returning early if auth is processing- Ensure processing flag resets correctly in finally block after submissionrefactor(theme): update ThemeData construction and theming details- Replace CardTheme with CardThemeData for card styling- Add explicit theming for scaffold background, app bar, and dialogs- Include input decoration, button, divider, list tile, bottom sheet, snackbar themes- Adjust usage of ColorScheme and apply Material3 style enhancementsfix(settings): handle default cases in theme mode label functions- Add default return values to _getThemeModeLabel for AppThemeMode and ColorSchemeType- Prevent potential unknown enum values causing undefined labels
1 parentc45fd71 commit0b72c81

File tree

3 files changed

+60
-15
lines changed

3 files changed

+60
-15
lines changed

‎lib/pages/auth/auth_page.dart‎

Lines changed: 26 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -85,6 +85,7 @@ class _AuthPageState extends State<AuthPage> {
8585
bool _isSurveyActive=false;
8686
bool _waitlistSuccess=false;
8787
String? _waitlistStatusMessage;
88+
bool _isProcessingAuth=false;// Add this flag to track auth processing
8889

8990
void_log(String message) {
9091
debugPrint('[AuthPage] $message');
@@ -652,16 +653,15 @@ class _AuthPageState extends State<AuthPage> {
652653
),
653654
),
654655
constSizedBox(height:16),
655-
CustomButton(
656-
text: isSignUp?'Create Account':'Sign In',
657-
onPressed: authState.isPerformingRequest? () {}: ()=>_handleSubmit(context),
658-
variant:ButtonVariant.filled,
659-
size:ButtonSize.large,
660-
),
661-
if (authState.isPerformingRequest)
662-
constPadding(
663-
padding:EdgeInsets.only(top:16),
664-
child:Center(child:CircularProgressIndicator()),
656+
// Modified button to show spinner when processing
657+
if (_isProcessingAuth)
658+
constCenter(child:CircularProgressIndicator())
659+
else
660+
CustomButton(
661+
text: isSignUp?'Create Account':'Sign In',
662+
onPressed: ()=>_handleSubmit(context),
663+
variant:ButtonVariant.filled,
664+
size:ButtonSize.large,
665665
),
666666
constSizedBox(height:16),
667667
_buildDivider(),
@@ -1043,12 +1043,20 @@ class _AuthPageState extends State<AuthPage> {
10431043
}
10441044

10451045
Future<void>_handleSubmit(BuildContext context)async {
1046+
// Prevent multiple clicks by checking if already processing
1047+
if (_isProcessingAuth)return;
1048+
10461049
final authState= context.read<AuthState>();
10471050
final form= _formKey.currentState;
10481051
if (form==null||!form.validate()) {
10491052
return;
10501053
}
10511054

1055+
// Set processing flag to true and update UI
1056+
setState(() {
1057+
_isProcessingAuth=true;
1058+
});
1059+
10521060
final email= _emailController.text.trim();
10531061
final password= _passwordController.text;
10541062
_log('Attempting submission for email=$email');
@@ -1103,6 +1111,7 @@ class _AuthPageState extends State<AuthPage> {
11031111
Navigator.pop(context);
11041112
setState(() {
11051113
_mode=_AuthMode.signIn;
1114+
_isProcessingAuth=false;// Reset processing flag
11061115
});
11071116
},
11081117
),
@@ -1128,6 +1137,13 @@ class _AuthPageState extends State<AuthPage> {
11281137
}catch (e) {
11291138
_log('Unexpected error surfaced to UI: $e');
11301139
_showSnackBar(context,'Something went wrong: $e', success:false);
1140+
}finally {
1141+
// Reset processing flag in finally block to ensure it's always reset
1142+
if (mounted) {
1143+
setState(() {
1144+
_isProcessingAuth=false;
1145+
});
1146+
}
11311147
}
11321148
}
11331149

‎lib/pages/settings_page.dart‎

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@ import '../models/user_profile.dart';
99
import'../services/auth_state.dart';
1010
import'../services/model_service.dart';
1111
import'../services/theme_service.dart';
12+
import'../models/theme_types.dart';// Add this import for AppThemeMode and ColorSchemeType
1213
import'auth/auth_flow_screen.dart';
1314
import'settings/profile/profile_settings.dart';
1415
import'api_keys_page.dart';
@@ -340,8 +341,6 @@ class _SettingsPageState extends State<SettingsPage> {
340341
);
341342
}
342343

343-
344-
345344
String_getThemeModeLabel(AppThemeMode mode) {
346345
switch (mode) {
347346
caseAppThemeMode.light:
@@ -352,6 +351,8 @@ class _SettingsPageState extends State<SettingsPage> {
352351
return'System';
353352
caseAppThemeMode.highContrast:
354353
return'High Contrast';
354+
default:
355+
return'Unknown';
355356
}
356357
}
357358

@@ -363,6 +364,8 @@ class _SettingsPageState extends State<SettingsPage> {
363364
return'High Contrast';
364365
caseColorSchemeType.custom:
365366
return'Custom';
367+
default:
368+
return'Unknown';
366369
}
367370
}
368371

‎lib/services/theme_service.dart‎

Lines changed: 29 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -200,10 +200,12 @@ class ThemeService extends ChangeNotifier {
200200

201201
ThemeData_buildThemeData(Brightness brightness,AppColorScheme appColorScheme) {
202202
final isDark= brightness==Brightness.dark;
203-
203+
204204
returnThemeData(
205205
brightness: brightness,
206206
useMaterial3:true,
207+
208+
// Color scheme
207209
colorScheme:ColorScheme(
208210
brightness: brightness,
209211
primary: appColorScheme.primary,
@@ -217,7 +219,11 @@ class ThemeService extends ChangeNotifier {
217219
background: appColorScheme.background,
218220
onBackground: appColorScheme.onBackground,
219221
),
222+
223+
// Scaffold
220224
scaffoldBackgroundColor: appColorScheme.background,
225+
226+
// App bar
221227
appBarTheme:AppBarTheme(
222228
backgroundColor: appColorScheme.surface,
223229
foregroundColor: appColorScheme.onSurface,
@@ -232,7 +238,9 @@ class ThemeService extends ChangeNotifier {
232238
fontWeight:FontWeight.w500,
233239
),
234240
),
235-
cardTheme:CardTheme(
241+
242+
// Cards
243+
cardTheme:CardThemeData(
236244
color: appColorScheme.cardBackground,
237245
shadowColor: appColorScheme.shadow,
238246
elevation:2,
@@ -241,6 +249,8 @@ class ThemeService extends ChangeNotifier {
241249
side:BorderSide(color: appColorScheme.cardBorder, width:0.5),
242250
),
243251
),
252+
253+
// Input decoration
244254
inputDecorationTheme:InputDecorationTheme(
245255
filled:true,
246256
fillColor: appColorScheme.inputBackground,
@@ -263,6 +273,8 @@ class ThemeService extends ChangeNotifier {
263273
hintStyle:TextStyle(color: appColorScheme.hint),
264274
labelStyle:TextStyle(color: appColorScheme.onSurface),
265275
),
276+
277+
// Elevated button
266278
elevatedButtonTheme:ElevatedButtonThemeData(
267279
style:ElevatedButton.styleFrom(
268280
backgroundColor: appColorScheme.primary,
@@ -274,6 +286,8 @@ class ThemeService extends ChangeNotifier {
274286
),
275287
),
276288
),
289+
290+
// Text button
277291
textButtonTheme:TextButtonThemeData(
278292
style:TextButton.styleFrom(
279293
foregroundColor: appColorScheme.primary,
@@ -282,6 +296,8 @@ class ThemeService extends ChangeNotifier {
282296
),
283297
),
284298
),
299+
300+
// Outlined button
285301
outlinedButtonTheme:OutlinedButtonThemeData(
286302
style:OutlinedButton.styleFrom(
287303
foregroundColor: appColorScheme.primary,
@@ -291,10 +307,14 @@ class ThemeService extends ChangeNotifier {
291307
),
292308
),
293309
),
310+
311+
// Divider
294312
dividerTheme:DividerThemeData(
295313
color: appColorScheme.divider,
296314
thickness:0.5,
297315
),
316+
317+
// List tile
298318
listTileTheme:ListTileThemeData(
299319
tileColor: appColorScheme.surface,
300320
textColor: appColorScheme.onSurface,
@@ -303,7 +323,9 @@ class ThemeService extends ChangeNotifier {
303323
borderRadius:BorderRadius.circular(8),
304324
),
305325
),
306-
dialogTheme:DialogTheme(
326+
327+
// Dialog
328+
dialogTheme:DialogThemeData(
307329
backgroundColor: appColorScheme.surface,
308330
surfaceTintColor: appColorScheme.primary,
309331
elevation:8,
@@ -312,6 +334,8 @@ class ThemeService extends ChangeNotifier {
312334
borderRadius:BorderRadius.circular(16),
313335
),
314336
),
337+
338+
// Bottom sheet
315339
bottomSheetTheme:BottomSheetThemeData(
316340
backgroundColor: appColorScheme.surface,
317341
surfaceTintColor: appColorScheme.primary,
@@ -321,6 +345,8 @@ class ThemeService extends ChangeNotifier {
321345
borderRadius:BorderRadius.vertical(top:Radius.circular(16)),
322346
),
323347
),
348+
349+
// Snack bar
324350
snackBarTheme:SnackBarThemeData(
325351
backgroundColor: isDark?Colors.grey[800]:Colors.grey[900],
326352
contentTextStyle:constTextStyle(color:Colors.white),

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp