Skip to content

Commit 6b520b6

Browse files
committed
app updated
1 parent faa0cee commit 6b520b6

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

52 files changed

+1758
-131
lines changed

.metadata

Lines changed: 0 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -18,21 +18,6 @@ migration:
1818
- platform: android
1919
create_revision: 2663184aa79047d0a33a14a3b607954f8fdd8730
2020
base_revision: 2663184aa79047d0a33a14a3b607954f8fdd8730
21-
- platform: ios
22-
create_revision: 2663184aa79047d0a33a14a3b607954f8fdd8730
23-
base_revision: 2663184aa79047d0a33a14a3b607954f8fdd8730
24-
- platform: linux
25-
create_revision: 2663184aa79047d0a33a14a3b607954f8fdd8730
26-
base_revision: 2663184aa79047d0a33a14a3b607954f8fdd8730
27-
- platform: macos
28-
create_revision: 2663184aa79047d0a33a14a3b607954f8fdd8730
29-
base_revision: 2663184aa79047d0a33a14a3b607954f8fdd8730
30-
- platform: web
31-
create_revision: 2663184aa79047d0a33a14a3b607954f8fdd8730
32-
base_revision: 2663184aa79047d0a33a14a3b607954f8fdd8730
33-
- platform: windows
34-
create_revision: 2663184aa79047d0a33a14a3b607954f8fdd8730
35-
base_revision: 2663184aa79047d0a33a14a3b607954f8fdd8730
3621

3722
# User provided section
3823

README.md

Lines changed: 48 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,3 +14,51 @@ A few resources to get you started if this is your first Flutter project:
1414
For help getting started with Flutter development, view the
1515
[online documentation](https://docs.flutter.dev/), which offers tutorials,
1616
samples, guidance on mobile development, and a full API reference.
17+
18+
19+
## File Structure
20+
21+
lib/
22+
├── core/
23+
│ ├── constants/
24+
│ │ └── app_routes.dart
25+
│ └── utils/
26+
│ └── validators.dart
27+
│ └── themes/
28+
│ └── dark_schemes.dart
29+
│ └── light_schemes.dart
30+
│ └── material_theme.dart
31+
│ └── theme_utils.dart
32+
├── data/
33+
│ ├── datasources/
34+
│ │ └── local_data_source.dart
35+
│ ├── models/
36+
│ │ └── task_model.dart
37+
│ ├── repositories/
38+
│ └── task_repository_impl.dart
39+
├── domain/
40+
│ ├── entities/
41+
│ │ └── task.dart
42+
│ ├── repositories/
43+
│ │ └── task_repository.dart
44+
│ ├── usecases/
45+
│ └── add_task.dart
46+
│ └── delete_task.dart
47+
│ └── get_tasks.dart
48+
│ └── update_task.dart
49+
├── l10n/
50+
│ ├── intl_en.arb
51+
│ ├── intl_es.arb
52+
├── presentation/
53+
│ ├── bloc/
54+
│ │ ├── task_bloc.dart
55+
│ │ ├── task_event.dart
56+
│ │ ├── task_state.dart
57+
│ ├── pages/
58+
│ │ └── task_page.dart
59+
│ ├── widgets/
60+
│ └── task_list.dart
61+
│ └── task_item.dart
62+
63+
├── injection_container.dart
64+
├── main.dart

lib/core/constants/app_routes.dart

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
// In this file you can find all the routes of the application
12
class AppRoutes {
23
static const String home = '/';
34
}

lib/core/themes/dark_schemes.dart

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,8 @@
11
import 'package:flutter/material.dart';
22

3-
/// Esquemas de colores para Dark Theme
3+
/// Color schemes for Dark Theme
44
class DarkSchemes {
5-
/// Esquema de colores para Dark Theme (Contraste Bajo)
5+
/// Color scheme for Dark Theme (Low Contrast)
66
static ColorScheme darkScheme() {
77
return const ColorScheme(
88
brightness: Brightness.dark,
@@ -54,7 +54,7 @@ class DarkSchemes {
5454
);
5555
}
5656

57-
/// Esquema de colores para Dark Theme (Contraste Medio)
57+
/// Color scheme for Dark Theme (Medium Contrast)
5858
static ColorScheme darkMediumContrastScheme() {
5959
return const ColorScheme(
6060
brightness: Brightness.dark,
@@ -106,7 +106,7 @@ class DarkSchemes {
106106
);
107107
}
108108

109-
/// Esquema de colores para Dark Theme (Contraste Alto)
109+
/// Dark Theme color scheme (High Contrast)
110110
static ColorScheme darkHighContrastScheme() {
111111
return const ColorScheme(
112112
brightness: Brightness.dark,

lib/core/themes/light_schemes.dart

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,8 @@
11
import 'package:flutter/material.dart';
22

3-
/// Esquemas de colores para Light Theme
3+
/// Color schemes for Light Theme
44
class LightSchemes {
5-
/// Esquema de colores para Light Theme (Contraste Bajo)
5+
/// Color scheme for Light Theme (Low Contrast)
66
static ColorScheme lightScheme() {
77
return const ColorScheme(
88
brightness: Brightness.light,
@@ -54,7 +54,7 @@ class LightSchemes {
5454
);
5555
}
5656

57-
/// Esquema de colores para Light Theme (Contraste Medio)
57+
/// Color scheme for Light Theme (Medium Contrast)
5858
static ColorScheme lightMediumContrastScheme() {
5959
return const ColorScheme(
6060
brightness: Brightness.light,
@@ -106,7 +106,7 @@ class LightSchemes {
106106
);
107107
}
108108

109-
/// Esquema de colores para Light Theme (Contraste Alto)
109+
/// Color scheme for Light Theme (High Contrast)
110110
static ColorScheme lightHighContrastScheme() {
111111
return const ColorScheme(
112112
brightness: Brightness.light,

lib/core/themes/material_theme.dart

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -3,36 +3,36 @@ import 'light_schemes.dart';
33
import 'dark_schemes.dart';
44
import 'theme_utils.dart';
55

6-
/// Clase para manejar temas personalizados
6+
/// Class for manage custom themes
77
class MaterialTheme {
88
const MaterialTheme();
99

10-
/// Tema para Light Scheme
10+
/// Theme for Light Scheme
1111
ThemeData light() {
1212
return ThemeUtils.theme(LightSchemes.lightScheme());
1313
}
1414

15-
/// Tema para Light Medium Contrast Scheme
15+
/// Theme for Light Medium Contrast Scheme
1616
ThemeData lightMediumContrast() {
1717
return ThemeUtils.theme(LightSchemes.lightMediumContrastScheme());
1818
}
1919

20-
/// Tema para Light High Contrast Scheme
20+
/// Theme for Light High Contrast Scheme
2121
ThemeData lightHighContrast() {
2222
return ThemeUtils.theme(LightSchemes.lightHighContrastScheme());
2323
}
2424

25-
/// Tema para Dark Scheme
25+
/// Theme for Dark Scheme
2626
ThemeData dark() {
2727
return ThemeUtils.theme(DarkSchemes.darkScheme());
2828
}
2929

30-
/// Tema para Dark Medium Contrast Scheme
30+
/// Theme for Medium dark contrast scheme
3131
ThemeData darkMediumContrast() {
3232
return ThemeUtils.theme(DarkSchemes.darkMediumContrastScheme());
3333
}
3434

35-
/// Tema para Dark High Contrast Scheme
35+
/// Theme for Dark High Contrast Scheme
3636
ThemeData darkHighContrast() {
3737
return ThemeUtils.theme(DarkSchemes.darkHighContrastScheme());
3838
}

lib/core/themes/theme_utils.dart

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,8 @@
11
import 'package:flutter/material.dart';
22

3-
/// Utilidades para temas
3+
/// Theme utilities
44
class ThemeUtils {
5-
/// Método común para crear ThemeData a partir de un ColorScheme
5+
/// Common method to create ThemeData from a ColorScheme
66
static ThemeData theme(
77
ColorScheme scheme,
88
) {

lib/core/utils/validators.dart

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,8 @@
1-
import 'package:intl/intl.dart'; // Para usar Intl
1+
import 'package:intl/intl.dart';
22

3+
/// this file is for the common validations in the application
34
class Validators {
4-
// Validado para campos requeridos
5+
// Validated for required fields
56
static String? requiredField(String? value) {
67
if (value == null || value.trim().isEmpty) {
78
return Intl.message("field_required");
Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,28 @@
1+
import '../models/task_model.dart';
2+
3+
/// Abstract class defining the contract for a local data source.
4+
///
5+
/// This interface declares methods for managing task data in a local storage
6+
/// system. Any implementation must define these methods to handle tasks.
7+
abstract class LocalDataSource {
8+
/// Retrieves a list of tasks from local storage.
9+
///
10+
/// Returns a [Future] containing a list of [TaskModel] objects.
11+
Future<List<TaskModel>> getTasks();
12+
13+
/// Saves a list of tasks to local storage.
14+
///
15+
/// Takes a list of [TaskModel] objects and persists them in storage.
16+
Future<void> saveTasks(List<TaskModel> tasks);
17+
18+
/// Deletes all tasks from local storage.
19+
///
20+
/// Removes all task data stored in the system.
21+
Future<void> deleteTasks();
22+
23+
/// Updates a specific task in local storage.
24+
///
25+
/// Takes a [TaskModel] object representing the updated task. The implementation
26+
/// should locate and replace the existing task with the provided one.
27+
Future<void> updateTask(TaskModel task);
28+
}
Lines changed: 94 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,94 @@
1+
import 'dart:convert';
2+
import 'package:shared_preferences/shared_preferences.dart';
3+
import '../models/task_model.dart';
4+
import 'local_data_source.dart';
5+
6+
/// Implementation of the LocalDataSource interface.
7+
/// Handles local storage operations for task data using SharedPreferences.
8+
class LocalDataSourceImpl implements LocalDataSource {
9+
/// SharedPreferences instance to manage persistent storage.
10+
final SharedPreferences sharedPreferences;
11+
12+
/// Constructor to initialize the SharedPreferences dependency.
13+
LocalDataSourceImpl(this.sharedPreferences);
14+
15+
/// Retrieves the list of tasks stored locally.
16+
///
17+
/// Decodes the JSON string stored in SharedPreferences into a list of
18+
/// [TaskModel] objects. Returns an empty list if no tasks are found.
19+
@override
20+
Future<List<TaskModel>> getTasks() async {
21+
try {
22+
// Fetch the stored JSON string associated with the 'tasks' key.
23+
final jsonString = sharedPreferences.getString('tasks');
24+
if (jsonString != null && jsonString.isNotEmpty) {
25+
// Parse the JSON string into a list of TaskModel instances.
26+
final List<dynamic> jsonList = json.decode(jsonString);
27+
return jsonList.map((json) => TaskModel.fromJson(json)).toList();
28+
}
29+
// Return an empty list if the storage is empty.
30+
return [];
31+
} catch (e) {
32+
// Handle and rethrow any errors encountered during the retrieval process.
33+
throw Exception("Error reading tasks: $e");
34+
}
35+
}
36+
37+
/// Saves the given list of tasks to local storage.
38+
///
39+
/// Encodes the list of [TaskModel] objects into a JSON string and stores
40+
/// it in SharedPreferences under the 'tasks' key.
41+
@override
42+
Future<void> saveTasks(List<TaskModel> tasks) async {
43+
try {
44+
// Convert the list of tasks to a JSON-compatible structure.
45+
final jsonList = tasks.map((task) => task.toJson()).toList();
46+
// Save the encoded JSON string into SharedPreferences.
47+
await sharedPreferences.setString('tasks', json.encode(jsonList));
48+
} catch (e) {
49+
// Handle and rethrow any errors encountered during the save process.
50+
throw Exception("Error saving tasks: $e");
51+
}
52+
}
53+
54+
/// Deletes all tasks from local storage.
55+
///
56+
/// Removes the value associated with the 'tasks' key in SharedPreferences.
57+
@override
58+
Future<void> deleteTasks() async {
59+
try {
60+
// Remove the 'tasks' key from SharedPreferences.
61+
await sharedPreferences.remove('tasks');
62+
} catch (e) {
63+
// Handle and rethrow any errors encountered during the deletion process.
64+
throw Exception("Error deleting tasks: $e");
65+
}
66+
}
67+
68+
/// Updates a specific task in the local storage.
69+
///
70+
/// Searches for the [updatedTask] in the stored task list by index. If found,
71+
/// updates the task and re-saves the modified list. Throws an exception if
72+
/// the task is not found.
73+
@override
74+
Future<void> updateTask(TaskModel updatedTask) async {
75+
try {
76+
// Fetch the current list of tasks.
77+
final tasks = await getTasks();
78+
// Find the index of the task to update.
79+
final taskIndex = tasks.indexWhere((task) => task == updatedTask);
80+
if (taskIndex != -1) {
81+
// Update the task at the found index.
82+
tasks[taskIndex] = updatedTask;
83+
// Save the updated task list.
84+
await saveTasks(tasks);
85+
} else {
86+
// Throw an error if the task is not found.
87+
throw Exception('Task not found');
88+
}
89+
} catch (e) {
90+
// Handle and rethrow any errors encountered during the update process.
91+
throw Exception("Error updating task: $e");
92+
}
93+
}
94+
}

0 commit comments

Comments
 (0)