|
| 1 | +import 'dart:convert'; |
| 2 | + |
| 3 | +import 'package:dev_doctor/editor/bloc/server.dart'; |
1 | 4 | import 'package:dev_doctor/widgets/appbar.dart'; |
2 | 5 | import 'package:flutter/material.dart'; |
3 | 6 | import 'package:easy_localization/easy_localization.dart'; |
| 7 | +import 'package:hive/hive.dart'; |
| 8 | +import 'package:hive_flutter/hive_flutter.dart'; |
4 | 9 |
|
5 | 10 | class EditorPage extends StatefulWidget { |
6 | 11 | @override |
7 | 12 | _EditorPageState createState() => _EditorPageState(); |
8 | 13 | } |
9 | 14 |
|
10 | 15 | class _EditorPageState extends State<EditorPage> { |
| 16 | + Box<String> _box = Hive.box<String>('editor'); |
11 | 17 | @override |
12 | 18 | Widget build(BuildContext context) { |
13 | 19 | return Scaffold( |
14 | 20 | appBar: MyAppBar(title: 'editor.title'.tr()), |
15 | | - body: Center(child: Text("coming-soon").tr())); |
| 21 | + body: ValueListenableBuilder( |
| 22 | + valueListenable: _box.listenable(), |
| 23 | + builder: (context, value, child) => Scrollbar( |
| 24 | + child: ListView.builder( |
| 25 | + itemCount: _box.length, |
| 26 | + itemBuilder: (context, index) { |
| 27 | + var item = json.decode(_box.getAt(index)); |
| 28 | + var bloc = ServerEditorBloc.fromJson(item); |
| 29 | + return ListTile(title: Text(bloc.server.name)); |
| 30 | + }))), |
| 31 | + floatingActionButton: FloatingActionButton.extended( |
| 32 | + onPressed: () {}, icon: Icon(Icons.add_outlined), label: Text("editor.create").tr())); |
16 | 33 | } |
17 | 34 | } |
0 commit comments