-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
ChenDoxiu
committed
Jun 16, 2024
1 parent
7046cde
commit f6d8497
Showing
25 changed files
with
871 additions
and
198 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,33 @@ | ||
import 'dart:convert'; | ||
|
||
import 'package:flutter/foundation.dart'; | ||
import 'package:hive/hive.dart'; | ||
import 'package:moekey/apis/models/note.dart'; | ||
import 'package:moekey/apis/models/user_full.dart'; | ||
import 'package:moekey/database/init_database.dart'; | ||
|
||
class UsersDatabase { | ||
/// 服务器地址 | ||
String server; | ||
|
||
/// 用户ID | ||
String userId; | ||
|
||
UsersDatabase({required this.server, required this.userId}); | ||
|
||
Future<LazyBox<String>> _getDatabase() async { | ||
return openLazyDatabase<String>(name: "users_cache"); | ||
} | ||
|
||
put(UserFullModel userFullModel) async { | ||
var db = await _getDatabase(); | ||
compute((message) { | ||
var json = jsonEncode(message); | ||
db.put(message.id, json); | ||
}, userFullModel); | ||
} | ||
|
||
get(String id) async { | ||
var db = await _getDatabase(); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,82 @@ | ||
import 'package:flutter/material.dart'; | ||
import 'package:flutter_hooks/flutter_hooks.dart'; | ||
import 'package:flutter_tabler_icons/flutter_tabler_icons.dart'; | ||
import 'package:hooks_riverpod/hooks_riverpod.dart'; | ||
import 'package:moekey/pages/explore/hot.dart'; | ||
import 'package:moekey/pages/explore/users.dart'; | ||
import 'package:moekey/status/themes.dart'; | ||
import 'package:moekey/widgets/mk_header.dart'; | ||
import 'package:moekey/widgets/mk_scaffold.dart'; | ||
|
||
import '../../widgets/keep_alive_wrapper.dart'; | ||
|
||
class ExplorePage extends HookConsumerWidget { | ||
const ExplorePage({super.key}); | ||
|
||
@override | ||
Widget build(BuildContext context, WidgetRef ref) { | ||
var themes = ref.watch(themeColorsProvider); | ||
var tabs = const [ | ||
Tab( | ||
child: Row( | ||
children: [ | ||
Icon( | ||
TablerIcons.bolt, | ||
size: 14, | ||
), | ||
Text("热门", style: TextStyle(fontSize: 12)), | ||
], | ||
), | ||
), | ||
Tab( | ||
child: Row( | ||
children: [ | ||
Icon(TablerIcons.users, size: 14), | ||
Text("用户", style: TextStyle(fontSize: 12)), | ||
], | ||
), | ||
) | ||
]; | ||
|
||
var tabController = useTabController(initialLength: tabs.length); | ||
|
||
var currentIndex = useState(0); | ||
tabController.addListener(() { | ||
currentIndex.value = tabController.index; | ||
}); | ||
|
||
return LayoutBuilder( | ||
builder: (context, constraints) { | ||
return MkScaffold( | ||
body: TabBarView( | ||
children: [ | ||
KeepAliveWrapper(child: ExploreHotPage()), | ||
KeepAliveWrapper(child: ExploreUsersPage()), | ||
], | ||
controller: tabController, | ||
), | ||
header: MkAppbar( | ||
leading: Padding( | ||
padding: const EdgeInsets.symmetric(horizontal: 8), | ||
child: Row( | ||
mainAxisSize: MainAxisSize.min, | ||
children: [ | ||
Icon(TablerIcons.hash, color: themes.fgColor, size: 18), | ||
const SizedBox(width: 4), | ||
const Text( | ||
"发现", | ||
) | ||
], | ||
), | ||
), | ||
isSmallLeadingCenter: constraints.maxWidth < 500, | ||
bottom: MkTabBar(controller: tabController, tabs: tabs), | ||
trailing: SizedBox( | ||
width: 100, | ||
), | ||
), | ||
); | ||
}, | ||
); | ||
} | ||
} |
Oops, something went wrong.