Skip to content

Commit b48cc32

Browse files
authored
Update home_screen.dart
1 parent 10cce4b commit b48cc32

File tree

1 file changed

+84
-9
lines changed

1 file changed

+84
-9
lines changed

lib/ui/screens/home_screen.dart

Lines changed: 84 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@ import 'dart:io';
22
import 'package:flutter/material.dart';
33
import '../../core/storage_service.dart';
44
import 'document_viewer_screen.dart';
5+
import 'settings_screen.dart'; // Importuj svoj novi settings fajl
56

67
class HomeScreen extends StatefulWidget {
78
const HomeScreen({super.key});
@@ -23,10 +24,14 @@ class _HomeScreenState extends State<HomeScreen> {
2324
context: context,
2425
builder: (context) {
2526
return AlertDialog(
26-
title: const Text("New Document"),
27+
title: const Text("New Document", style: TextStyle(fontWeight: FontWeight.w300)),
2728
content: TextField(
29+
autofocus: true,
2830
onChanged: (value) => newFileName = value,
29-
decoration: const InputDecoration(hintText: "Enter file name"),
31+
decoration: const InputDecoration(
32+
hintText: "Enter file name",
33+
border: UnderlineInputBorder(),
34+
),
3035
),
3136
actions: [
3237
TextButton(
@@ -63,6 +68,50 @@ class _HomeScreenState extends State<HomeScreen> {
6368
appBar: AppBar(
6469
title: const Text("f.Sentence", style: TextStyle(fontWeight: FontWeight.w300)),
6570
centerTitle: true,
71+
// Hamburger ikona
72+
leading: Builder(
73+
builder: (context) => IconButton(
74+
icon: const Icon(Icons.menu),
75+
onPressed: () => Scaffold.of(context).openDrawer(),
76+
),
77+
),
78+
),
79+
// Meni sa leve strane
80+
drawer: Drawer(
81+
child: Column(
82+
children: [
83+
DrawerHeader(
84+
decoration: BoxDecoration(
85+
color: Theme.of(context).colorScheme.surfaceContainerHighest.withOpacity(0.5),
86+
),
87+
child: const Center(
88+
child: Text(
89+
"f.Sentence",
90+
style: TextStyle(fontSize: 28, fontWeight: FontWeight.w200),
91+
),
92+
),
93+
),
94+
ListTile(
95+
leading: const Icon(Icons.settings_outlined),
96+
title: const Text("Settings"),
97+
onTap: () {
98+
Navigator.pop(context); // Zatvori meni
99+
Navigator.push(
100+
context,
101+
MaterialPageRoute(builder: (_) => const SettingsScreen()),
102+
).then((_) => _refreshList());
103+
},
104+
),
105+
const Spacer(),
106+
const Padding(
107+
padding: EdgeInsets.all(16.0),
108+
child: Text(
109+
"v1.0.1",
110+
style: TextStyle(color: Colors.grey, fontSize: 12),
111+
),
112+
),
113+
],
114+
),
66115
),
67116
body: FutureBuilder<List<File>>(
68117
future: StorageService.getLocalFiles(),
@@ -72,27 +121,52 @@ class _HomeScreenState extends State<HomeScreen> {
72121
}
73122

74123
if (!snapshot.hasData || snapshot.data!.isEmpty) {
75-
return const Center(
76-
child: Text("No documents yet.", style: TextStyle(color: Colors.grey)),
124+
return Center(
125+
child: Column(
126+
mainAxisAlignment: MainAxisAlignment.center,
127+
children: [
128+
Icon(Icons.note_add_outlined, size: 64, color: Colors.grey.withOpacity(0.5)),
129+
const SizedBox(height: 16),
130+
const Text("No documents yet.", style: TextStyle(color: Colors.grey)),
131+
],
132+
),
77133
);
78134
}
79135

80136
final files = snapshot.data!;
81137

82138
return ListView.builder(
83-
padding: const EdgeInsets.all(12),
139+
padding: const EdgeInsets.symmetric(horizontal: 16, vertical: 8),
84140
itemCount: files.length,
85141
itemBuilder: (context, index) {
86142
final file = files[index];
87143
final fileName = file.path.split('/').last;
88144

89145
return Card(
90146
elevation: 0,
91-
color: Theme.of(context).colorScheme.surfaceVariant.withOpacity(0.3),
92-
margin: const EdgeInsets.only(bottom: 8),
147+
shape: RoundedRectangleBorder(
148+
borderRadius: BorderRadius.circular(16),
149+
side: BorderSide(
150+
color: Theme.of(context).colorScheme.outlineVariant,
151+
width: 1,
152+
),
153+
),
154+
margin: const EdgeInsets.only(bottom: 12),
93155
child: ListTile(
94-
leading: const Icon(Icons.article_outlined),
95-
title: Text(fileName),
156+
contentPadding: const EdgeInsets.symmetric(horizontal: 20, vertical: 8),
157+
leading: CircleAvatar(
158+
backgroundColor: Theme.of(context).colorScheme.primaryContainer,
159+
child: Icon(Icons.article_outlined,
160+
color: Theme.of(context).colorScheme.onPrimaryContainer),
161+
),
162+
title: Text(
163+
fileName,
164+
style: const TextStyle(fontWeight: FontWeight.w400),
165+
),
166+
subtitle: Text(
167+
"Last modified: ${file.lastModifiedSync().day}.${file.lastModifiedSync().month}.${file.lastModifiedSync().year}",
168+
style: TextStyle(fontSize: 12, color: Colors.grey[600]),
169+
),
96170
onTap: () {
97171
Navigator.push(
98172
context,
@@ -111,6 +185,7 @@ class _HomeScreenState extends State<HomeScreen> {
111185
onPressed: _showCreateDialog,
112186
label: const Text("New Note"),
113187
icon: const Icon(Icons.add),
188+
elevation: 2,
114189
),
115190
);
116191
}

0 commit comments

Comments
 (0)