From f67a153ed725cd30cd03343422b6e82c245a3e49 Mon Sep 17 00:00:00 2001 From: misakajimmy Date: Sat, 14 Jan 2023 18:30:33 +0800 Subject: [PATCH] DEV UPDATE:Add member filter --- {jsons => Jsons}/cacheConfig.json | 0 {jsons => Jsons}/video.json | 0 {jsons => Jsons}/videos.json | 0 android/app/build.gradle | 1 + lib/common/Global.dart | 57 ++++---- lib/main.dart | 14 +- lib/models/eoeTheme.dart | 3 +- lib/models/eoeTheme.g.dart | 2 + lib/models/index.dart | 2 +- lib/models/member.dart | 19 ++- lib/models/member.g.dart | 4 + lib/models/memberMap.dart | 29 ---- lib/models/memberMap.g.dart | 27 ---- lib/models/theme.dart | 16 ++ lib/models/theme.g.dart | 14 ++ lib/routes/mainPage.dart | 74 ++++++---- lib/routes/video/videoList.dart | 87 +++++++---- lib/routes/video/videoListItem.dart | 18 ++- lib/routes/video/videoMemberFilter.dart | 79 ++++++++++ lib/routes/video/videoPage.dart | 14 +- macos/Flutter/GeneratedPluginRegistrant.swift | 4 + pubspec.lock | 137 +++++++++++++++++- pubspec.yaml | 4 +- 23 files changed, 434 insertions(+), 171 deletions(-) rename {jsons => Jsons}/cacheConfig.json (100%) rename {jsons => Jsons}/video.json (100%) rename {jsons => Jsons}/videos.json (100%) delete mode 100644 lib/models/memberMap.dart delete mode 100644 lib/models/memberMap.g.dart create mode 100644 lib/models/theme.dart create mode 100644 lib/models/theme.g.dart create mode 100644 lib/routes/video/videoMemberFilter.dart diff --git a/jsons/cacheConfig.json b/Jsons/cacheConfig.json similarity index 100% rename from jsons/cacheConfig.json rename to Jsons/cacheConfig.json diff --git a/jsons/video.json b/Jsons/video.json similarity index 100% rename from jsons/video.json rename to Jsons/video.json diff --git a/jsons/videos.json b/Jsons/videos.json similarity index 100% rename from jsons/videos.json rename to Jsons/videos.json diff --git a/android/app/build.gradle b/android/app/build.gradle index 5252051..4e835c5 100644 --- a/android/app/build.gradle +++ b/android/app/build.gradle @@ -26,6 +26,7 @@ apply plugin: 'kotlin-android' apply from: "$flutterRoot/packages/flutter_tools/gradle/flutter.gradle" android { + compileSdkVersion 33 compileSdkVersion flutter.compileSdkVersion ndkVersion flutter.ndkVersion diff --git a/lib/common/Global.dart b/lib/common/Global.dart index 95e2339..7d0c958 100644 --- a/lib/common/Global.dart +++ b/lib/common/Global.dart @@ -1,7 +1,7 @@ import 'dart:convert'; import 'package:eoe_fans/models/eoeTheme.dart'; -import 'package:eoe_fans/models/memberMap.dart'; +import 'package:eoe_fans/models/member.dart'; import 'package:flutter/material.dart'; import 'package:shared_preferences/shared_preferences.dart'; @@ -14,71 +14,67 @@ const _themes = [ 'id': 'zao', 'name': 'zao', 'assetsPath': 'zao', + 'filter': 'emoji/gogo队.webp' }, - { - 'id': 'wan', - 'name': 'wan', - 'assetsPath': 'zao', - }, - { - 'id': 'mo', - 'name': 'mo', - 'assetsPath': 'zao', - }, - { - 'id': 'un', - 'name': 'un', - 'assetsPath': 'zao', - }, - { - 'id': 'mi', - 'name': 'mi', - 'assetsPath': 'zao', - } + {'id': 'wan', 'name': 'wan', 'assetsPath': 'wan', 'filter': 'emoji/小莞熊.webp'}, + {'id': 'mo', 'name': 'mo', 'assetsPath': 'mo', 'filter': 'emoji/美人虞.webp'}, + {'id': 'un', 'name': 'un', 'assetsPath': 'un', 'filter': 'emoji/柚恩蜜.webp'}, + {'id': 'mi', 'name': 'mi', 'assetsPath': 'mi', 'filter': 'emoji/酷诺米.webp'} ]; -const Map membersJson = { - 'zao': { +const Map membersJson = { + MemberEnum.zao: { + 'key': 'zao', 'lastName': '白', 'firstName': '露早', 'bilibiliName': '露早GOGO', 'bilibiliUID': 1669777785, 'nickNames': ['早早'], + 'color': '#3DFF9E', }, - 'wan': { + MemberEnum.wan: { + 'key': 'wan', 'lastName': '唐', 'firstName': '莞儿', 'bilibiliName': '莞儿睡不醒', 'bilibiliUID': 1875044092, - 'nickNames': [''], + 'nickNames': ['莞莞'], + 'color': '#1EAFE4', }, - 'mo': { + MemberEnum.mo: { + 'key': 'mo', 'lastName': '苏', 'firstName': '虞莫', 'bilibiliName': '虞莫MOMO', 'bilibiliUID': 1811071010, 'nickNames': ['莫莫'], + 'color': '#B77FDD', }, - 'un': { + MemberEnum.un: { + 'key': 'un', 'lastName': '姜', 'firstName': '柚恩', 'bilibiliName': '柚恩不加糖', 'bilibiliUID': 1795147802, 'nickNames': ['柚柚'], + 'color': '#EB6346', }, - 'mi': { + MemberEnum.mi: { + 'key': 'mi', 'lastName': '安', 'firstName': '米诺', 'bilibiliName': '米诺高分少女', 'bilibiliUID': 1778026586, 'nickNames': ['大米'], + 'color': '#F068B0', } }; class Global { static late SharedPreferences _prefs; static Profile profile = Profile(); - static MemberMap members = MemberMap.fromJson(membersJson); + + static Map get members => membersJson.map((key, value) => MapEntry(key, Member.fromJson(value))); //网络缓存对象 static NetCache netCache = NetCache(); @@ -86,7 +82,8 @@ class Global { static String currentTheme = 'zao'; //可选主题列表 - static List get themes => _themes.map((e) => EoeTheme.fromJson(e)).toList(); + static List get themes => + _themes.map((e) => EoeTheme.fromJson(e)).toList(); //是否为release版 static bool get isRelease => bool.fromEnvironment("dart.vm.product"); diff --git a/lib/main.dart b/lib/main.dart index 36292ce..e784d18 100644 --- a/lib/main.dart +++ b/lib/main.dart @@ -2,20 +2,20 @@ import 'dart:io'; import 'package:eoe_fans/routes/mainPage.dart'; import 'package:flutter/material.dart'; -import 'package:flutter/services.dart'; import 'package:eoe_fans/states/ProfileChangeNotifier.dart'; +import 'package:flutter/services.dart'; import 'package:provider/provider.dart'; import 'common/Global.dart'; void main() { WidgetsFlutterBinding.ensureInitialized(); - // if (Platform.isAndroid) { - // // 以下两行 设置android状态栏为透明的沉浸。写在组件渲染之后,是为了在渲染后进行set赋值,覆盖状态栏,写在渲染之前MaterialApp组件会覆盖掉这个值。 - // SystemUiOverlayStyle systemUiOverlayStyle = - // SystemUiOverlayStyle(statusBarColor: Colors.transparent); - // SystemChrome.setSystemUIOverlayStyle(systemUiOverlayStyle); - // } + if (Platform.isAndroid) { + // 以下两行 设置android状态栏为透明的沉浸。写在组件渲染之后,是为了在渲染后进行set赋值,覆盖状态栏,写在渲染之前MaterialApp组件会覆盖掉这个值。 + SystemUiOverlayStyle systemUiOverlayStyle = + SystemUiOverlayStyle(statusBarColor: Colors.transparent); + SystemChrome.setSystemUIOverlayStyle(systemUiOverlayStyle); + } Global.init().then((e) => runApp(MyApp())); } diff --git a/lib/models/eoeTheme.dart b/lib/models/eoeTheme.dart index c2c3646..aaeeb55 100644 --- a/lib/models/eoeTheme.dart +++ b/lib/models/eoeTheme.dart @@ -4,11 +4,12 @@ part 'eoeTheme.g.dart'; @JsonSerializable() class EoeTheme { - EoeTheme({required this.id, required this.name, required this.assetsPath}); + EoeTheme({required this.id, required this.name, required this.assetsPath,required this.filter}); String id; String name; String assetsPath; + String filter; factory EoeTheme.fromJson(Map json) => _$EoeThemeFromJson(json); diff --git a/lib/models/eoeTheme.g.dart b/lib/models/eoeTheme.g.dart index 2289000..a349931 100644 --- a/lib/models/eoeTheme.g.dart +++ b/lib/models/eoeTheme.g.dart @@ -10,10 +10,12 @@ EoeTheme _$EoeThemeFromJson(Map json) => EoeTheme( id: json['id'] as String, name: json['name'] as String, assetsPath: json['assetsPath'] as String, + filter: json['filter'] as String, ); Map _$EoeThemeToJson(EoeTheme instance) => { 'id': instance.id, 'name': instance.name, 'assetsPath': instance.assetsPath, + 'filter': instance.filter, }; diff --git a/lib/models/index.dart b/lib/models/index.dart index 038914a..95bc529 100644 --- a/lib/models/index.dart +++ b/lib/models/index.dart @@ -1,3 +1,3 @@ export 'cacheConfig.dart' ; -export 'video.dart' ; export 'videos.dart' ; +export 'video.dart' ; diff --git a/lib/models/member.dart b/lib/models/member.dart index 046a3c8..c2b3abf 100644 --- a/lib/models/member.dart +++ b/lib/models/member.dart @@ -2,16 +2,31 @@ import 'package:json_annotation/json_annotation.dart'; part 'member.g.dart'; +enum MemberEnum { + @JsonValue("zao") + zao, + @JsonValue("wan") + wan, + @JsonValue("mi") + mi, + @JsonValue("un") + un, + @JsonValue("mo") + mo, +} + @JsonSerializable() class Member { - Member(this.lastName, this.firstName, this.bilibiliName, this.bilibiliUID, - this.nickNames); + Member(this.key ,this.lastName, this.firstName, this.bilibiliName, this.bilibiliUID, + this.nickNames, this.color); + String key; String lastName; String firstName; String bilibiliName; num bilibiliUID; List nickNames; + String color; factory Member.fromJson(Map json) => _$MemberFromJson(json); diff --git a/lib/models/member.g.dart b/lib/models/member.g.dart index 282332c..89038da 100644 --- a/lib/models/member.g.dart +++ b/lib/models/member.g.dart @@ -7,17 +7,21 @@ part of 'member.dart'; // ************************************************************************** Member _$MemberFromJson(Map json) => Member( + json['key'] as String, json['lastName'] as String, json['firstName'] as String, json['bilibiliName'] as String, json['bilibiliUID'] as num, (json['nickNames'] as List).map((e) => e as String).toList(), + json['color'] as String, ); Map _$MemberToJson(Member instance) => { + 'key': instance.key, 'lastName': instance.lastName, 'firstName': instance.firstName, 'bilibiliName': instance.bilibiliName, 'bilibiliUID': instance.bilibiliUID, 'nickNames': instance.nickNames, + 'color': instance.color, }; diff --git a/lib/models/memberMap.dart b/lib/models/memberMap.dart deleted file mode 100644 index a10a33d..0000000 --- a/lib/models/memberMap.dart +++ /dev/null @@ -1,29 +0,0 @@ -import 'package:json_annotation/json_annotation.dart'; - -import 'member.dart'; - -part 'memberMap.g.dart'; - -enum MemberEnum { - @JsonValue("zao") - LUZAO, - @JsonValue("wan") - WANER, - @JsonValue("mi") - MINUO, - @JsonValue("un") - YOUEN, - @JsonValue("mo") - YUMO, -} - -@JsonSerializable() -class MemberMap { - MemberMap(this.members); - - Map members; - - factory MemberMap.fromJson(Map json) => _$MemberMapFromJson(json); - - Map toJson() => _$MemberMapToJson(this); -} diff --git a/lib/models/memberMap.g.dart b/lib/models/memberMap.g.dart deleted file mode 100644 index c55d322..0000000 --- a/lib/models/memberMap.g.dart +++ /dev/null @@ -1,27 +0,0 @@ -// GENERATED CODE - DO NOT MODIFY BY HAND - -part of 'memberMap.dart'; - -// ************************************************************************** -// JsonSerializableGenerator -// ************************************************************************** - -MemberMap _$MemberMapFromJson(Map json) => MemberMap( - (json['members'] as Map).map( - (k, e) => MapEntry($enumDecode(_$MemberEnumEnumMap, k), - Member.fromJson(e as Map)), - ), - ); - -Map _$MemberMapToJson(MemberMap instance) => { - 'members': - instance.members.map((k, e) => MapEntry(_$MemberEnumEnumMap[k]!, e)), - }; - -const _$MemberEnumEnumMap = { - MemberEnum.LUZAO: 'zao', - MemberEnum.WANER: 'wan', - MemberEnum.MINUO: 'mi', - MemberEnum.YOUEN: 'un', - MemberEnum.YUMO: 'mo', -}; diff --git a/lib/models/theme.dart b/lib/models/theme.dart new file mode 100644 index 0000000..422505a --- /dev/null +++ b/lib/models/theme.dart @@ -0,0 +1,16 @@ +import 'package:json_annotation/json_annotation.dart'; +import 'package:flutter/material.dart'; + +part 'theme.g.dart'; + +@JsonSerializable() +class Theme { + Theme(); + + late String themeName; + // late ThemeData themeData; + + factory Theme.fromJson(Map json) => _$ThemeFromJson(json); + + Map toJson() => _$ThemeToJson(this); +} diff --git a/lib/models/theme.g.dart b/lib/models/theme.g.dart new file mode 100644 index 0000000..7efc363 --- /dev/null +++ b/lib/models/theme.g.dart @@ -0,0 +1,14 @@ +// GENERATED CODE - DO NOT MODIFY BY HAND + +part of 'theme.dart'; + +// ************************************************************************** +// JsonSerializableGenerator +// ************************************************************************** + +Theme _$ThemeFromJson(Map json) => + Theme()..themeName = json['themeName'] as String; + +Map _$ThemeToJson(Theme instance) => { + 'themeName': instance.themeName, + }; diff --git a/lib/routes/mainPage.dart b/lib/routes/mainPage.dart index e9deea3..0e37add 100644 --- a/lib/routes/mainPage.dart +++ b/lib/routes/mainPage.dart @@ -29,38 +29,48 @@ class _MainPageState extends State { @override Widget build(BuildContext context) { return Scaffold( - body: IndexedStack( - index: _selectedIndex, - children: _bodyList, - ), - bottomNavigationBar: Container( - decoration: BoxDecoration( - image: DecorationImage( - image: AssetImage( - 'assets/${Provider.of(context).assets}/tail_bg.png'), - fit: BoxFit.fill), - color: Colors.transparent), - child: BottomNavigationBar( - elevation: 0, - backgroundColor: Colors.transparent, - items: const [ - BottomNavigationBarItem( - icon: Icon(Icons.image), - label: '视频', - ), - BottomNavigationBarItem( - icon: Icon(Icons.image), - backgroundColor: Colors.transparent, - label: '图片', - ), - BottomNavigationBarItem( - icon: Icon(Icons.library_music), - label: '音乐', - ), - ], - currentIndex: _selectedIndex, - onTap: _onItemTapped, - ))); + body: Stack( + children: [ + IndexedStack( + index: _selectedIndex, + children: _bodyList, + ), + Align( + alignment: Alignment.bottomCenter, + child: Theme( + data: Theme.of(context) + .copyWith(canvasColor: Colors.transparent), + child: Container( + decoration: BoxDecoration( + image: DecorationImage( + image: AssetImage( + 'assets/${Provider.of(context).assets}/tail_bg.png'), + fit: BoxFit.fill), + color: Colors.transparent), + child: BottomNavigationBar( + elevation: 0, + backgroundColor: Colors.transparent, + type: BottomNavigationBarType.fixed, + items: const [ + BottomNavigationBarItem( + icon: Icon(Icons.video_library_outlined), + label: '视频', + ), + BottomNavigationBarItem( + icon: Icon(Icons.image), + label: '图片', + ), + BottomNavigationBarItem( + icon: Icon(Icons.library_music), + label: '音乐', + ), + ], + currentIndex: _selectedIndex, + onTap: _onItemTapped, + )))) + ], + ), + ); } void _onItemTapped(int index) { diff --git a/lib/routes/video/videoList.dart b/lib/routes/video/videoList.dart index 98004e4..cc01188 100644 --- a/lib/routes/video/videoList.dart +++ b/lib/routes/video/videoList.dart @@ -1,8 +1,12 @@ import 'package:eoe_fans/common/Api.dart'; +import 'package:eoe_fans/models/member.dart'; import 'package:eoe_fans/models/video.dart'; import 'package:eoe_fans/models/videos.dart'; import 'package:eoe_fans/models/videosRequest.dart'; import 'package:eoe_fans/routes/video/videoListItem.dart'; +import 'package:eoe_fans/routes/video/videoMemberFilter.dart'; +import 'package:eoe_fans/common/Global.dart'; +import 'package:flutter_staggered_grid_view/flutter_staggered_grid_view.dart'; import 'package:flutter/material.dart'; class VideoList extends StatefulWidget { @@ -17,8 +21,9 @@ class VideoList extends StatefulWidget { class _VideoListState extends State { late final bool? origin; - int _len = 100; int _page = -1; + MemberEnum? _memberFilter; + bool _loading = false; List