Browse Source

update file page UI

pull/18/head
Sun 4 years ago
parent
commit
ef28b610ef
  1. 151
      lib/apps/file/list.dart

151
lib/apps/file/list.dart

@ -12,19 +12,14 @@ class FilesList extends StatefulWidget {
} }
const List FILE_DIRECTORY = [ const List FILE_DIRECTORY = [
["Recent", Icons.label_rounded], ["Starred", Icons.star],
["Starred", Icons.star_rounded], ["Documents", Icons.description],
["Home", Icons.home_rounded], ["Pictures", Icons.photo],
["Documents", Icons.my_library_books_rounded], ["Media", Icons.music_video],
["Pictures", Icons.collections_rounded], ["Trash", Icons.auto_delete],
["Music", Icons.my_library_music_rounded],
["Videos", Icons.video_collection_rounded],
["Trash", Icons.auto_delete_rounded],
]; ];
class _FilesListState extends State<FilesList> { class _FilesListState extends State<FilesList> {
int chooseIndex = 0;
@override @override
void initState() { void initState() {
super.initState(); super.initState();
@ -35,37 +30,35 @@ class _FilesListState extends State<FilesList> {
// //
} }
changeItem(int index, bool isDesktop) { changeItem(String name, bool isDesktop) {
setState(() { setState(() {
chooseIndex = index; // chooseIndex = index;
// loadFolder(isDesktop, index); // loadFolder(isDesktop, index);
}); });
} }
Widget item(int index, ColorScheme color, bool isDesktop) { Widget item(String name, IconData icon, ColorScheme color, bool isDesktop) {
return GestureDetector( return Container(
behavior: HitTestBehavior.opaque, width: 140,
onTap: () => changeItem(index, isDesktop), height: 50,
child: SizedBox(
height: 55.0,
child: Row(
children: [
Container(
width: 45.0,
height: 45.0,
margin: const EdgeInsets.only(left: 20.0, right: 15.0),
child: Icon(FILE_DIRECTORY[index][1], size: 24.0, color: color.primary),
decoration: BoxDecoration( decoration: BoxDecoration(
color: color.surface, color: color.surface,
borderRadius: BorderRadius.circular(15.0) borderRadius: BorderRadius.circular(15.0),
),
),
chooseIndex == index
? Text(FILE_DIRECTORY[index][0], style: TextStyle(fontSize: 16.0, color: color.primary))
: Text(FILE_DIRECTORY[index][0], style: TextStyle(fontSize: 16.0))
],
), ),
child: InkWell(
onTap: () => changeItem(name, isDesktop),
child: Row(
mainAxisAlignment: MainAxisAlignment.center,
children: [
Padding(
padding: const EdgeInsets.only(left: 16.0, right: 8.0),
child: Icon(icon, color: color.primary),
), ),
Expanded(
child: Text(name, style: TextStyle(fontSize: 14.0))
)
]
)),
); );
} }
@ -75,6 +68,10 @@ class _FilesListState extends State<FilesList> {
final lang = AppLocalizations.of(context); final lang = AppLocalizations.of(context);
final isDesktop = isDisplayDesktop(context); final isDesktop = isDisplayDesktop(context);
final List<Widget> widgets = FILE_DIRECTORY.map(
(i) => item(i[0], i[1], color, isDesktop)
).toList();
return Scaffold( return Scaffold(
appBar: AppBar( appBar: AppBar(
title: Text(lang.files + ' (${lang.wip})'), title: Text(lang.files + ' (${lang.wip})'),
@ -84,30 +81,61 @@ class _FilesListState extends State<FilesList> {
), ),
), ),
body: Padding( body: Padding(
padding: const EdgeInsets.symmetric(vertical: 10.0), padding: const EdgeInsets.all(10.0),
child: ListView.builder( child: ListView(
itemCount: FILE_DIRECTORY.length, children: [
itemBuilder: (BuildContext ctx, int index) => item(index, color, isDesktop), const SizedBox(height: 10.0),
Wrap(
spacing: 8.0,
runSpacing: 8.0,
alignment: WrapAlignment.start,
children: widgets
),
const SizedBox(height: 36.0),
Text('Recents', style: Theme.of(context).textTheme.title),
const SizedBox(height: 16.0),
Wrap(
spacing: 4.0,
runSpacing: 8.0,
alignment: WrapAlignment.start,
children: <Widget> [
FileItem(name: 'myworks.dir'),
FileItem(name: 'ESSE-infos-public.dir'),
FileItem(name: 'personal.dir'),
FileItem(name: 'others.dir'),
FileItem(name: 'logo.jpg'),
FileItem(name: 'cat.png'),
FileItem(name: 'what-is-esse_en.doc'),
FileItem(name: '20210101-customers.xls'),
FileItem(name: 'product.pdf'),
FileItem(name: 'deck.ppt'),
FileItem(name: 'coder.md'),
FileItem(name: 'how-to-live-in-happy.mp4'),
FileItem(name: 'something_important'),
FileItem(name: 'car.json'),
],
),
]
) )
), ),
); );
} }
} }
class FilePage extends StatelessWidget { class FileItem extends StatelessWidget {
final String title; final String name;
const FilePage({Key key, this.title}) : super(key: key); const FileItem({Key key, this.name}) : super(key: key);
String remove_dir(String name) { String remove_dir(String name) {
if (name.endsWith('.dir')) { if (name.endsWith('.dir')) {
final i = name.lastIndexOf('.'); final i = name.lastIndexOf('.');
return name.substring(0, i); return name.substring(0, i);
} }
return name; return name;
} }
Widget item(String name) { @override
Widget build(BuildContext context) {
final trueName = remove_dir(name); final trueName = remove_dir(name);
return Container( return Container(
width: 80.0, width: 80.0,
@ -118,17 +146,22 @@ class FilePage extends StatelessWidget {
Container( Container(
height: 60.0, height: 60.0,
width: 60.0, width: 60.0,
padding: const EdgeInsets.only(bottom: 10.0),
child: fileIcon(name, 48.0), child: fileIcon(name, 48.0),
), ),
Tooltip( Tooltip(
message: trueName, message: trueName,
child: Text(trueName, style: TextStyle(fontSize: 16.0), maxLines: 1, overflow: TextOverflow.ellipsis), child: Text(trueName,
style: TextStyle(fontSize: 14.0), maxLines: 1, overflow: TextOverflow.ellipsis),
) )
] ]
) )
); );
} }
}
class FilePage extends StatelessWidget {
final String title;
const FilePage({Key key, this.title}) : super(key: key);
@override @override
Widget build(BuildContext context) { Widget build(BuildContext context) {
@ -137,8 +170,7 @@ class FilePage extends StatelessWidget {
final lang = AppLocalizations.of(context); final lang = AppLocalizations.of(context);
return Scaffold( return Scaffold(
body: SafeArea( body: Padding(
child: Padding(
padding: const EdgeInsets.all(10.0), padding: const EdgeInsets.all(10.0),
child: Column( child: Column(
mainAxisAlignment: MainAxisAlignment.start, mainAxisAlignment: MainAxisAlignment.start,
@ -223,27 +255,26 @@ class FilePage extends StatelessWidget {
runSpacing: 16.0, runSpacing: 16.0,
alignment: WrapAlignment.start, alignment: WrapAlignment.start,
children: <Widget> [ children: <Widget> [
item('myworks.dir'), FileItem(name: 'myworks.dir'),
item('ESSE-infos-public.dir'), FileItem(name: 'ESSE-infos-public.dir'),
item('personal.dir'), FileItem(name: 'personal.dir'),
item('others.dir'), FileItem(name: 'others.dir'),
item('logo.jpg'), FileItem(name: 'logo.jpg'),
item('cat.png'), FileItem(name: 'cat.png'),
item('what-is-esse_en.doc'), FileItem(name: 'what-is-esse_en.doc'),
item('20210101-customers.xls'), FileItem(name: '20210101-customers.xls'),
item('product.pdf'), FileItem(name: 'product.pdf'),
item('deck.ppt'), FileItem(name: 'deck.ppt'),
item('coder.md'), FileItem(name: 'coder.md'),
item('how-to-live-in-happy.mp4'), FileItem(name: 'how-to-live-in-happy.mp4'),
item('something_important'), FileItem(name: 'something_important'),
item('car.json'), FileItem(name: 'car.json'),
], ],
) )
) )
] ]
) )
) )
)
); );
} }
} }

Loading…
Cancel
Save