Skip to content

Commit 55d6b30

Browse files
committed
correções internas
1 parent 455e8db commit 55d6b30

File tree

11 files changed

+136
-122
lines changed

11 files changed

+136
-122
lines changed

CHANGELOG.md

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,14 @@ Changelog Tarefas
22

33
======================================================
44

5+
## [3.0.1](https://github.com/hendrilmendes/Tarefas/compare/3.0.0..3.0.1) (03-08-2025)
6+
7+
### Correções
8+
9+
- Correções internas
10+
11+
======================================================
12+
513
## [3.0.0](https://github.com/hendrilmendes/Tarefas/compare/2.4.2..3.0.0) (20-06-2025)
614

715
## Alterações

android/build.gradle

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ subprojects {
1010
project.buildDir = "${rootProject.buildDir}/${project.name}"
1111
afterEvaluate {
1212
android {
13-
compileSdkVersion 34
13+
compileSdkVersion 35
1414
}
1515
}
1616
}

lib/auth/auth.dart

Lines changed: 36 additions & 40 deletions
Original file line numberDiff line numberDiff line change
@@ -1,58 +1,54 @@
11
import 'package:firebase_auth/firebase_auth.dart';
22
import 'package:flutter/foundation.dart';
33
import 'package:google_sign_in/google_sign_in.dart';
4-
import 'package:connectivity_plus/connectivity_plus.dart';
54

65
class AuthService {
76
final FirebaseAuth _auth = FirebaseAuth.instance;
8-
final GoogleSignIn _googleSignIn = GoogleSignIn();
7+
final GoogleSignIn _googleSignIn = GoogleSignIn.instance;
8+
bool _isGoogleSignInInitialized = false;
99

10-
// Função para autenticação com Google
11-
Future<User?> signInWithGoogle() async {
10+
Future<void> _initializeGoogleSignIn() async {
1211
try {
13-
// Verificação de conectividade
14-
final connectivityResults = await Connectivity().checkConnectivity();
15-
if (connectivityResults.contains(ConnectivityResult.none)) {
16-
if (kDebugMode) print("Sem conexão com a internet");
17-
return null;
12+
await _googleSignIn.initialize();
13+
_isGoogleSignInInitialized = true;
14+
} catch (e) {
15+
if (kDebugMode) {
16+
print('Falha ao inicializar o Google Sign-In: $e');
1817
}
18+
}
19+
}
1920

20-
// Realizar login com Google
21-
final GoogleSignInAccount? googleSignInAccount = await _googleSignIn
22-
.signIn();
23-
if (googleSignInAccount == null) {
24-
if (kDebugMode) print("Login cancelado pelo usuário.");
25-
return null;
26-
}
21+
Future<void> _ensureGoogleSignInInitialized() async {
22+
if (!_isGoogleSignInInitialized) {
23+
await _initializeGoogleSignIn();
24+
}
25+
}
2726

28-
// Autenticação no Firebase com as credenciais do Google
29-
final GoogleSignInAuthentication googleAuth =
30-
await googleSignInAccount.authentication;
31-
final AuthCredential credential = GoogleAuthProvider.credential(
32-
accessToken: googleAuth.accessToken,
33-
idToken: googleAuth.idToken,
34-
);
27+
// Função para autenticação com Google
28+
Future<UserCredential?> signInWithGoogle() async {
29+
await _ensureGoogleSignInInitialized();
30+
try {
31+
final GoogleSignInAccount googleSignInAccount = await _googleSignIn
32+
.authenticate();
3533

36-
final UserCredential authResult = await _auth.signInWithCredential(
37-
credential,
38-
);
39-
final User? user = authResult.user;
34+
final GoogleSignInAuthentication googleAuth =
35+
googleSignInAccount.authentication;
36+
final idToken = googleAuth.idToken;
4037

41-
if (user != null) {
42-
if (kDebugMode) {
43-
print('Usuário autenticado com sucesso: ${user.displayName}');
44-
}
45-
} else {
46-
if (kDebugMode) print('Erro: Autenticação retornou usuário nulo.');
38+
if (idToken == null) {
39+
throw Exception('Não foi possível obter o token de ID do Google.');
4740
}
4841

49-
return user;
50-
} on FirebaseAuthException catch (e) {
51-
if (kDebugMode) print('Erro do Firebase na autenticação: ${e.message}');
52-
return null;
53-
} on Exception catch (e) {
54-
if (kDebugMode) print('Erro desconhecido na autenticação: $e');
55-
return null;
42+
final AuthCredential credential = GoogleAuthProvider.credential(
43+
accessToken: googleAuth.idToken,
44+
idToken: idToken,
45+
);
46+
47+
return await _auth.signInWithCredential(credential);
48+
} catch (e) {
49+
if (kDebugMode) print('Erro na autenticação com Google: $e');
50+
await signOut();
51+
rethrow;
5652
}
5753
}
5854

lib/l10n/app_localizations.dart

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -475,7 +475,7 @@ abstract class AppLocalizations {
475475
/// No description provided for @notificationSub.
476476
///
477477
/// In pt, this message translates to:
478-
/// **'Serão enviadas notificações sobre suas tarefas'**
478+
/// **'Notificações sobre suas tarefas'**
479479
String get notificationSub;
480480

481481
/// No description provided for @confirmDeleteTask.

lib/l10n/app_localizations_pt.dart

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -201,8 +201,7 @@ class AppLocalizationsPt extends AppLocalizations {
201201
String get notification => 'Notificações';
202202

203203
@override
204-
String get notificationSub =>
205-
'Serão enviadas notificações sobre suas tarefas';
204+
String get notificationSub => 'Notificações sobre suas tarefas';
206205

207206
@override
208207
String get confirmDeleteTask => 'Deseja realmente apagar a tarefa?';

lib/l10n/app_pt.arb

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -126,7 +126,7 @@
126126
"@inputNoteError": {},
127127
"notification": "Notificações",
128128
"@notification": {},
129-
"notificationSub": "Serão enviadas notificações sobre suas tarefas",
129+
"notificationSub": "Notificações sobre suas tarefas",
130130
"@notificationSub": {},
131131
"confirmDeleteTask": "Deseja realmente apagar a tarefa?",
132132
"@confirmDeleteTask": {},

lib/screens/settings/personalization/personalization.dart

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -157,7 +157,7 @@ class _PersonalizationScreenState extends State<PersonalizationScreen> {
157157
CupertinoSlidingSegmentedControl<ThemeModeType>(
158158
backgroundColor: colors.surface.withOpacity(
159159
0.4,
160-
), // Cor de fundo mais integrada
160+
),
161161
thumbColor: colors.primary,
162162
groupValue: themeModel.themeMode,
163163
onValueChanged: (ThemeModeType? newValue) {

lib/screens/settings/settings.dart

Lines changed: 16 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -292,7 +292,6 @@ class _SettingsScreenState extends State<SettingsScreen>
292292
context,
293293
icon: CupertinoIcons.bell_fill,
294294
title: AppLocalizations.of(context)!.notification,
295-
subtitle: AppLocalizations.of(context)!.notificationSub,
296295
color: Theme.of(context).colorScheme.secondary,
297296
onTap: () {
298297
AppSettings.openAppSettings(
@@ -311,7 +310,7 @@ class _SettingsScreenState extends State<SettingsScreen>
311310
BuildContext context, {
312311
required IconData icon,
313312
required String title,
314-
required String subtitle,
313+
String? subtitle,
315314
required Color color,
316315
required VoidCallback onTap,
317316
}) {
@@ -366,20 +365,22 @@ class _SettingsScreenState extends State<SettingsScreen>
366365
maxLines: 1,
367366
overflow: TextOverflow.ellipsis,
368367
),
369-
const SizedBox(height: 1),
370-
Text(
371-
subtitle,
372-
style: TextStyle(
373-
fontSize: 11,
374-
color: Theme.of(
375-
context,
376-
).colorScheme.onSurface.withOpacity(0.6),
377-
fontWeight: FontWeight.w500,
378-
height: 1.2,
368+
if (subtitle != null) ...[
369+
const SizedBox(height: 1),
370+
Text(
371+
subtitle,
372+
style: TextStyle(
373+
fontSize: 11,
374+
color: Theme.of(
375+
context,
376+
).colorScheme.onSurface.withOpacity(0.6),
377+
fontWeight: FontWeight.w500,
378+
height: 1.2,
379+
),
380+
maxLines: 1,
381+
overflow: TextOverflow.ellipsis,
379382
),
380-
maxLines: 1,
381-
overflow: TextOverflow.ellipsis,
382-
),
383+
],
383384
],
384385
),
385386
),

lib/theme/theme.dart

Lines changed: 20 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,16 @@
1+
import 'dart:io';
2+
import 'package:device_info_plus/device_info_plus.dart';
13
import 'package:flutter/material.dart';
24
import 'package:shared_preferences/shared_preferences.dart';
35

46
enum ThemeModeType { light, dark, system }
57

68
class ThemeModel extends ChangeNotifier {
79
bool _isDarkMode = true;
8-
bool _isDynamicColorsEnabled = true;
9-
ThemeModeType _themeMode = ThemeModeType.light;
10+
bool _isDynamicColorsEnabled = false;
11+
ThemeModeType _themeMode = ThemeModeType.system;
12+
13+
bool _isAndroid12OrHigher = false;
1014

1115
final List<MaterialColor> availableAccentColors = [
1216
Colors.amber,
@@ -27,18 +31,15 @@ class ThemeModel extends ChangeNotifier {
2731
static const String darkModeKey = 'darkModeEnabled';
2832
static const String dynamicColorsKey = 'dynamicColorsEnabled';
2933
static const String themeModeKey = 'themeMode';
30-
3134
static const String primaryColorKey = 'primaryColorIndex';
3235

3336
ThemeModel() {
3437
_primaryColor = availableAccentColors[1];
35-
_loadThemePreference();
3638
}
3739

3840
bool get isDarkMode => _isDarkMode;
3941
bool get isDynamicColorsEnabled => _isDynamicColorsEnabled;
4042
ThemeModeType get themeMode => _themeMode;
41-
4243
MaterialColor get primaryColor => _primaryColor;
4344

4445
void toggleDarkMode() {
@@ -48,9 +49,11 @@ class ThemeModel extends ChangeNotifier {
4849
}
4950

5051
void toggleDynamicColors() {
51-
_isDynamicColorsEnabled = !_isDynamicColorsEnabled;
52-
_savePreference(dynamicColorsKey, _isDynamicColorsEnabled);
53-
notifyListeners();
52+
if (_isAndroid12OrHigher) {
53+
_isDynamicColorsEnabled = !_isDynamicColorsEnabled;
54+
_savePreference(dynamicColorsKey, _isDynamicColorsEnabled);
55+
notifyListeners();
56+
}
5457
}
5558

5659
void changeThemeMode(ThemeModeType mode) {
@@ -66,11 +69,18 @@ class ThemeModel extends ChangeNotifier {
6669
notifyListeners();
6770
}
6871

69-
Future<void> _loadThemePreference() async {
72+
Future<void> initialize() async {
73+
if (Platform.isAndroid) {
74+
final androidInfo = await DeviceInfoPlugin().androidInfo;
75+
_isAndroid12OrHigher = androidInfo.version.sdkInt >= 31;
76+
}
77+
7078
SharedPreferences prefs = await SharedPreferences.getInstance();
7179

80+
final userPrefersDynamic = prefs.getBool(dynamicColorsKey) ?? false;
81+
_isDynamicColorsEnabled = userPrefersDynamic && _isAndroid12OrHigher;
82+
7283
_isDarkMode = prefs.getBool(darkModeKey) ?? true;
73-
_isDynamicColorsEnabled = prefs.getBool(dynamicColorsKey) ?? true;
7484
_themeMode = _getSavedThemeMode(prefs.getString(themeModeKey));
7585

7686
int colorIndex = prefs.getInt(primaryColorKey) ?? 1;

0 commit comments

Comments
 (0)