-
Notifications
You must be signed in to change notification settings - Fork 390
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
Showing
44 changed files
with
2,464 additions
and
223 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
Binary file modified
BIN
+756 Bytes
(240%)
simple_live_tv_app/android/app/src/main/res/mipmap-hdpi/ic_launcher.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added
BIN
+979 Bytes
simple_live_tv_app/android/app/src/main/res/mipmap-ldpi/ic_launcher.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified
BIN
+799 Bytes
(280%)
simple_live_tv_app/android/app/src/main/res/mipmap-mdpi/ic_launcher.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified
BIN
+1.04 KB
(250%)
simple_live_tv_app/android/app/src/main/res/mipmap-xhdpi/ic_launcher.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified
BIN
+1.83 KB
(280%)
simple_live_tv_app/android/app/src/main/res/mipmap-xxhdpi/ic_launcher.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified
BIN
+2.41 KB
(270%)
simple_live_tv_app/android/app/src/main/res/mipmap-xxxhdpi/ic_launcher.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
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
72 changes: 72 additions & 0 deletions
72
simple_live_tv_app/lib/modules/category/category_controller.dart
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,72 @@ | ||
import 'package:get/get.dart'; | ||
import 'package:simple_live_core/simple_live_core.dart'; | ||
import 'package:simple_live_tv_app/app/app_focus_node.dart'; | ||
import 'package:simple_live_tv_app/app/constant.dart'; | ||
import 'package:simple_live_tv_app/app/controller/base_controller.dart'; | ||
import 'package:simple_live_tv_app/app/sites.dart'; | ||
|
||
class CategoryController extends BasePageController<AppLiveCategory> { | ||
var siteId = Constant.kBiliBili.obs; | ||
var site = Sites.allSites[Constant.kBiliBili]!; | ||
|
||
@override | ||
void onInit() { | ||
refreshData(); | ||
super.onInit(); | ||
} | ||
|
||
void setSite(String id) { | ||
siteId.value = id; | ||
site = Sites.allSites[id]!; | ||
refreshData(); | ||
} | ||
|
||
@override | ||
Future<List<AppLiveCategory>> getData(int page, int pageSize) async { | ||
var result = await site.liveSite.getCategores(); | ||
|
||
return result.map((e) => AppLiveCategory.fromLiveCategory(e)).toList(); | ||
} | ||
} | ||
|
||
class AppLiveCategory extends LiveCategory { | ||
var showAll = false.obs; | ||
final List<LiveSubCategoryExt> childrenExt; | ||
AppLiveCategory({ | ||
required super.id, | ||
required super.name, | ||
required super.children, | ||
}) : childrenExt = children | ||
.map((e) => LiveSubCategoryExt( | ||
id: e.id, | ||
name: e.name, | ||
parentId: e.parentId, | ||
pic: e.pic, | ||
)) | ||
.toList() { | ||
showAll.value = children.length < 19; | ||
} | ||
|
||
List<LiveSubCategoryExt> get take15 => childrenExt.take(15).toList(); | ||
|
||
AppFocusNode moreFocusNode = AppFocusNode(); | ||
|
||
factory AppLiveCategory.fromLiveCategory(LiveCategory item) { | ||
return AppLiveCategory( | ||
children: item.children, | ||
id: item.id, | ||
name: item.name, | ||
); | ||
} | ||
} | ||
|
||
class LiveSubCategoryExt extends LiveSubCategory { | ||
LiveSubCategoryExt({ | ||
required super.id, | ||
required super.name, | ||
required super.parentId, | ||
super.pic, | ||
}); | ||
|
||
AppFocusNode focusNode = AppFocusNode(); | ||
} |
199 changes: 199 additions & 0 deletions
199
simple_live_tv_app/lib/modules/category/category_page.dart
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,199 @@ | ||
import 'package:flutter/material.dart'; | ||
import 'package:flutter_screenutil/flutter_screenutil.dart'; | ||
import 'package:simple_live_tv_app/routes/app_navigation.dart'; | ||
import 'package:simple_live_tv_app/widgets/highlight_widget.dart'; | ||
import 'package:simple_live_tv_app/widgets/net_image.dart'; | ||
import 'package:get/get.dart'; | ||
import 'package:simple_live_tv_app/app/app_focus_node.dart'; | ||
import 'package:simple_live_tv_app/app/app_style.dart'; | ||
import 'package:simple_live_tv_app/app/sites.dart'; | ||
import 'package:simple_live_tv_app/modules/category/category_controller.dart'; | ||
import 'package:simple_live_tv_app/widgets/app_scaffold.dart'; | ||
import 'package:simple_live_tv_app/widgets/button/highlight_button.dart'; | ||
|
||
class CategoryPage extends GetView<CategoryController> { | ||
const CategoryPage({super.key}); | ||
|
||
@override | ||
Widget build(BuildContext context) { | ||
return AppScaffold( | ||
child: Column( | ||
children: [ | ||
AppStyle.vGap32, | ||
Row( | ||
crossAxisAlignment: CrossAxisAlignment.center, | ||
children: [ | ||
AppStyle.hGap48, | ||
HighlightButton( | ||
focusNode: AppFocusNode(), | ||
iconData: Icons.arrow_back, | ||
text: "返回", | ||
autofocus: true, | ||
onTap: () { | ||
Get.back(); | ||
}, | ||
), | ||
AppStyle.hGap32, | ||
Text( | ||
"直播类目", | ||
style: AppStyle.titleStyleWhite.copyWith( | ||
fontSize: 36.w, | ||
fontWeight: FontWeight.bold, | ||
), | ||
), | ||
AppStyle.hGap24, | ||
const Spacer(), | ||
Obx( | ||
() => Visibility( | ||
visible: controller.loadding.value, | ||
child: SizedBox( | ||
width: 48.w, | ||
height: 48.w, | ||
child: CircularProgressIndicator( | ||
color: Colors.white, | ||
strokeWidth: 4.w, | ||
), | ||
), | ||
), | ||
), | ||
// AppStyle.hGap24, | ||
// HighlightButton( | ||
// focusNode: AppFocusNode(), | ||
// iconData: Icons.refresh, | ||
// text: "刷新", | ||
// onTap: () { | ||
// controller.refreshData(); | ||
// }, | ||
// ), | ||
AppStyle.hGap48, | ||
], | ||
), | ||
AppStyle.vGap24, | ||
Wrap( | ||
alignment: WrapAlignment.center, | ||
spacing: 36.w, | ||
children: Sites.supportSites | ||
.map( | ||
(e) => Obx( | ||
() => HighlightButton( | ||
icon: Image.asset( | ||
e.logo, | ||
width: 48.w, | ||
height: 48.w, | ||
), | ||
text: e.name, | ||
selected: controller.siteId.value == e.id, | ||
focusNode: AppFocusNode(), | ||
onTap: () { | ||
controller.setSite(e.id); | ||
}, | ||
), | ||
), | ||
) | ||
.toList(), | ||
), | ||
AppStyle.vGap24, | ||
Expanded( | ||
child: Obx( | ||
() => ListView.builder( | ||
padding: AppStyle.edgeInsetsH48, | ||
itemCount: controller.list.length, | ||
controller: controller.scrollController, | ||
itemBuilder: (_, i) { | ||
var item = controller.list[i]; | ||
return Column( | ||
crossAxisAlignment: CrossAxisAlignment.stretch, | ||
children: [ | ||
Padding( | ||
padding: AppStyle.edgeInsetsV32, | ||
child: Text( | ||
item.name, | ||
style: AppStyle.titleStyleWhite, | ||
), | ||
), | ||
Obx( | ||
() => GridView.count( | ||
shrinkWrap: true, | ||
padding: AppStyle.edgeInsetsV8, | ||
physics: const NeverScrollableScrollPhysics(), | ||
crossAxisCount: 8, | ||
crossAxisSpacing: 8, | ||
mainAxisSpacing: 8, | ||
children: item.showAll.value | ||
? (item.childrenExt | ||
.map( | ||
(e) => buildSubCategory(e), | ||
) | ||
.toList()) | ||
: (item.take15 | ||
.map( | ||
(e) => buildSubCategory(e), | ||
) | ||
.toList() | ||
..add(buildShowMore(item))), | ||
), | ||
), | ||
], | ||
); | ||
}, | ||
), | ||
), | ||
), | ||
], | ||
), | ||
); | ||
} | ||
|
||
Widget buildSubCategory(LiveSubCategoryExt item) { | ||
return HighlightWidget( | ||
focusNode: item.focusNode, | ||
onTap: () { | ||
AppNavigator.toCategoryDetail(site: controller.site, category: item); | ||
}, | ||
color: Colors.white10, | ||
borderRadius: AppStyle.radius16, | ||
child: Column( | ||
mainAxisAlignment: MainAxisAlignment.center, | ||
children: [ | ||
NetImage( | ||
item.pic ?? "", | ||
width: 64.w, | ||
height: 64.w, | ||
borderRadius: 16.w, | ||
cacheWidth: 100, | ||
), | ||
AppStyle.vGap12, | ||
Text( | ||
item.name, | ||
maxLines: 1, | ||
textAlign: TextAlign.center, | ||
style: item.focusNode.isFoucsed.value | ||
? AppStyle.textStyleBlack | ||
: AppStyle.textStyleWhite, | ||
), | ||
], | ||
), | ||
); | ||
} | ||
|
||
Widget buildShowMore(AppLiveCategory item) { | ||
return HighlightWidget( | ||
focusNode: item.moreFocusNode, | ||
onTap: () { | ||
item.showAll.value = true; | ||
}, | ||
color: Colors.white10, | ||
borderRadius: AppStyle.radius16, | ||
child: Center( | ||
child: Text( | ||
"显示全部", | ||
maxLines: 1, | ||
textAlign: TextAlign.center, | ||
style: item.moreFocusNode.isFoucsed.value | ||
? AppStyle.textStyleBlack | ||
: AppStyle.textStyleWhite, | ||
), | ||
), | ||
); | ||
} | ||
} |
Oops, something went wrong.