fix
This commit is contained in:
Vendored
+31
@@ -0,0 +1,31 @@
|
||||
{
|
||||
// Use IntelliSense to learn about possible attributes.
|
||||
// Hover to view descriptions of existing attributes.
|
||||
// For more information, visit: https://go.microsoft.com/fwlink/?linkid=830387
|
||||
"version": "0.2.0",
|
||||
"configurations": [
|
||||
{
|
||||
"name": "Flutter",
|
||||
"type": "dart",
|
||||
"request": "launch",
|
||||
"program": "lib/main.dart"
|
||||
},
|
||||
{
|
||||
"name": "budget_app",
|
||||
"request": "launch",
|
||||
"type": "dart"
|
||||
},
|
||||
{
|
||||
"name": "budget_app (profile mode)",
|
||||
"request": "launch",
|
||||
"type": "dart",
|
||||
"flutterMode": "profile"
|
||||
},
|
||||
{
|
||||
"name": "budget_app (release mode)",
|
||||
"request": "launch",
|
||||
"type": "dart",
|
||||
"flutterMode": "release"
|
||||
}
|
||||
]
|
||||
}
|
||||
@@ -36,6 +36,8 @@ class _HomePageState extends State<HomePage> {
|
||||
final authState = context.read<AuthBloc>().state;
|
||||
if (authState is AuthAuthenticated) {
|
||||
_currentUserId = authState.user.id;
|
||||
// Загружаем транзакции через глобальный TransactionBloc
|
||||
context.read<TransactionBloc>().add(LoadTransactions(userId: _currentUserId));
|
||||
} else {
|
||||
// Если пользователь не аутентифицирован, можно перенаправить на страницу входа
|
||||
// или использовать ID по умолчанию, если это применимо.
|
||||
@@ -56,12 +58,7 @@ class _HomePageState extends State<HomePage> {
|
||||
context,
|
||||
)!; // Получаем экземпляр локализации
|
||||
|
||||
return BlocProvider(
|
||||
create: (context) {
|
||||
return GetIt.instance<TransactionBloc>()
|
||||
..add(LoadTransactions(userId: _currentUserId));
|
||||
},
|
||||
child: Scaffold(
|
||||
return Scaffold(
|
||||
appBar: AppBar(
|
||||
title: Text(localizations.appTitle), // Локализованный заголовок
|
||||
// Кнопки действий в AppBar теперь не нужны, так как настройки перенесены в BottomNavigationBar
|
||||
@@ -99,7 +96,6 @@ class _HomePageState extends State<HomePage> {
|
||||
selectedItemColor: Theme.of(context).colorScheme.primary,
|
||||
onTap: _onItemTapped,
|
||||
),
|
||||
),
|
||||
);
|
||||
}
|
||||
}
|
||||
@@ -203,85 +199,3 @@ class TransactionsPage extends StatelessWidget {
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
class HomeView extends StatelessWidget {
|
||||
const HomeView({super.key});
|
||||
|
||||
// //
|
||||
// Основной метод построения интерфейса виджета.
|
||||
//
|
||||
// Возвращает Scaffold - базовую структуру страницы Material Design,
|
||||
// которая включает:
|
||||
// 1. AppBar (верхнюю панель)
|
||||
// 2. Body (основное содержимое)
|
||||
// //
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
final localizations = AppLocalizations.of(
|
||||
context,
|
||||
)!; // Получаем экземпляр локализации
|
||||
|
||||
return Scaffold(
|
||||
// Верхняя панель приложения
|
||||
appBar: AppBar(
|
||||
// Заголовок приложения
|
||||
title: const Text('Budget App'),
|
||||
|
||||
// Кнопки в правой части AppBar
|
||||
actions: [
|
||||
// Кнопка настроек
|
||||
IconButton(
|
||||
icon: const Icon(Icons.settings),
|
||||
onPressed: () {
|
||||
Navigator.push(
|
||||
context,
|
||||
MaterialPageRoute(builder: (context) => const SettingsPage()),
|
||||
);
|
||||
},
|
||||
tooltip: 'Настройки',
|
||||
),
|
||||
],
|
||||
),
|
||||
|
||||
body: BlocBuilder<TransactionBloc, TransactionState>(
|
||||
builder: (context, state) {
|
||||
if (state is TransactionLoading) {
|
||||
return const Center(child: CircularProgressIndicator());
|
||||
} else if (state is TransactionLoaded) {
|
||||
if (state.transactions.isEmpty) {
|
||||
return const Center(child: Text('Нет транзакций'));
|
||||
}
|
||||
return ListView.builder(
|
||||
itemCount: state.transactions.length,
|
||||
itemBuilder: (context, index) {
|
||||
final transaction = state.transactions[index];
|
||||
return ListTile(
|
||||
leading: Icon(
|
||||
transaction.category.icon,
|
||||
color: transaction.category.color,
|
||||
),
|
||||
title: Text(transaction.vendor),
|
||||
subtitle: Text(transaction.category.name),
|
||||
trailing: Text(
|
||||
'${transaction.amount.toStringAsFixed(2)} ${transaction.currency}',
|
||||
style: TextStyle(
|
||||
color: transaction.isIncome ? Colors.green : Colors.red,
|
||||
),
|
||||
),
|
||||
);
|
||||
},
|
||||
);
|
||||
} else if (state is TransactionError) {
|
||||
return Center(
|
||||
child: Text(localizations.transactionErrorText(state.message)),
|
||||
); // Локализованный текст
|
||||
} else {
|
||||
return Center(
|
||||
child: Text(localizations.loadingTransactionsText),
|
||||
); // Локализованный текст
|
||||
}
|
||||
},
|
||||
),
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user