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"
|
||||||
|
}
|
||||||
|
]
|
||||||
|
}
|
||||||
+39
-125
@@ -36,6 +36,8 @@ class _HomePageState extends State<HomePage> {
|
|||||||
final authState = context.read<AuthBloc>().state;
|
final authState = context.read<AuthBloc>().state;
|
||||||
if (authState is AuthAuthenticated) {
|
if (authState is AuthAuthenticated) {
|
||||||
_currentUserId = authState.user.id;
|
_currentUserId = authState.user.id;
|
||||||
|
// Загружаем транзакции через глобальный TransactionBloc
|
||||||
|
context.read<TransactionBloc>().add(LoadTransactions(userId: _currentUserId));
|
||||||
} else {
|
} else {
|
||||||
// Если пользователь не аутентифицирован, можно перенаправить на страницу входа
|
// Если пользователь не аутентифицирован, можно перенаправить на страницу входа
|
||||||
// или использовать ID по умолчанию, если это применимо.
|
// или использовать ID по умолчанию, если это применимо.
|
||||||
@@ -56,49 +58,43 @@ class _HomePageState extends State<HomePage> {
|
|||||||
context,
|
context,
|
||||||
)!; // Получаем экземпляр локализации
|
)!; // Получаем экземпляр локализации
|
||||||
|
|
||||||
return BlocProvider(
|
return Scaffold(
|
||||||
create: (context) {
|
appBar: AppBar(
|
||||||
return GetIt.instance<TransactionBloc>()
|
title: Text(localizations.appTitle), // Локализованный заголовок
|
||||||
..add(LoadTransactions(userId: _currentUserId));
|
// Кнопки действий в AppBar теперь не нужны, так как настройки перенесены в BottomNavigationBar
|
||||||
},
|
),
|
||||||
child: Scaffold(
|
body: Center(
|
||||||
appBar: AppBar(
|
child: _widgetOptions[_selectedIndex], // Отображаем выбранный виджет
|
||||||
title: Text(localizations.appTitle), // Локализованный заголовок
|
),
|
||||||
// Кнопки действий в AppBar теперь не нужны, так как настройки перенесены в BottomNavigationBar
|
floatingActionButton: FloatingActionButton(
|
||||||
),
|
onPressed: () {
|
||||||
body: Center(
|
showDialog(
|
||||||
child: _widgetOptions[_selectedIndex], // Отображаем выбранный виджет
|
context: context,
|
||||||
),
|
builder: (BuildContext context) {
|
||||||
floatingActionButton: FloatingActionButton(
|
return const AddTransactionDialog();
|
||||||
onPressed: () {
|
},
|
||||||
showDialog(
|
);
|
||||||
context: context,
|
},
|
||||||
builder: (BuildContext context) {
|
child: const Icon(Icons.add),
|
||||||
return const AddTransactionDialog();
|
),
|
||||||
},
|
bottomNavigationBar: BottomNavigationBar(
|
||||||
);
|
items: <BottomNavigationBarItem>[
|
||||||
},
|
BottomNavigationBarItem(
|
||||||
child: const Icon(Icons.add),
|
icon: const Icon(Icons.home),
|
||||||
),
|
label: localizations.homePageTitle, // Локализованный текст
|
||||||
bottomNavigationBar: BottomNavigationBar(
|
),
|
||||||
items: <BottomNavigationBarItem>[
|
BottomNavigationBarItem(
|
||||||
BottomNavigationBarItem(
|
icon: const Icon(Icons.bar_chart),
|
||||||
icon: const Icon(Icons.home),
|
label: localizations.reportsPageTitle, // Локализованный текст
|
||||||
label: localizations.homePageTitle, // Локализованный текст
|
),
|
||||||
),
|
BottomNavigationBarItem(
|
||||||
BottomNavigationBarItem(
|
icon: const Icon(Icons.settings),
|
||||||
icon: const Icon(Icons.bar_chart),
|
label: localizations.settingsPageTitle, // Локализованный текст
|
||||||
label: localizations.reportsPageTitle, // Локализованный текст
|
),
|
||||||
),
|
],
|
||||||
BottomNavigationBarItem(
|
currentIndex: _selectedIndex,
|
||||||
icon: const Icon(Icons.settings),
|
selectedItemColor: Theme.of(context).colorScheme.primary,
|
||||||
label: localizations.settingsPageTitle, // Локализованный текст
|
onTap: _onItemTapped,
|
||||||
),
|
|
||||||
],
|
|
||||||
currentIndex: _selectedIndex,
|
|
||||||
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