Skip to content

Commit

Permalink
TV端初步完成开发
Browse files Browse the repository at this point in the history
  • Loading branch information
xiaoyaocz committed Mar 8, 2024
1 parent e7112c7 commit 15ce795
Show file tree
Hide file tree
Showing 44 changed files with 2,464 additions and 223 deletions.
7 changes: 3 additions & 4 deletions simple_live_app/lib/modules/tv_sync/tv_sync_page.dart
Original file line number Diff line number Diff line change
Expand Up @@ -69,12 +69,11 @@ class TVSyncPage extends GetView<TVSyncController> {
contentPadding: AppStyle.edgeInsetsH12,
trailing: IconButton(
visualDensity: VisualDensity.compact,
onPressed: () {},
onPressed: () {
TVService.instance.refreshClients();
},
icon: const Icon(Icons.refresh),
),
onTap: () {
TVService.instance.refreshClients();
},
),
SettingsCard(
child: Obx(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
<uses-permission android:name="android.permission.READ_EXTERNAL_STORAGE"/>
<uses-permission android:name="android.permission.MANAGE_EXTERNAL_STORAGE" />
<application
android:label="simple_live_tv_app"
android:label="Simple Live TV"
android:name="${applicationName}"
android:icon="@mipmap/ic_launcher"
android:networkSecurityConfig="@xml/network_security_config"
Expand Down
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
10 changes: 5 additions & 5 deletions simple_live_tv_app/lib/app/controller/base_controller.dart
Original file line number Diff line number Diff line change
Expand Up @@ -11,8 +11,8 @@ class BaseController extends GetxController {
/// 加载中,更新页面
var pageLoadding = false.obs;

/// 加载中,不会更新页面
var loadding = false;
/// 加载中
var loadding = false.obs;

/// 空白页面
var pageEmpty = false.obs;
Expand Down Expand Up @@ -74,8 +74,8 @@ class BasePageController<T> extends BaseController {

Future loadData() async {
try {
if (loadding) return;
loadding = true;
if (loadding.value) return;
loadding.value = true;
pageError.value = false;
pageEmpty.value = false;
notLogin.value = false;
Expand All @@ -102,7 +102,7 @@ class BasePageController<T> extends BaseController {
} catch (e) {
handleError(e, showPageError: currentPage == 1);
} finally {
loadding = false;
loadding.value = false;
pageLoadding.value = false;
}
}
Expand Down
36 changes: 32 additions & 4 deletions simple_live_tv_app/lib/app/utils.dart
Original file line number Diff line number Diff line change
Expand Up @@ -47,19 +47,47 @@ class Utils {
}) async {
var result = await Get.dialog(
AlertDialog(
title: Text(title),
shape: RoundedRectangleBorder(
borderRadius: AppStyle.radius16,
),
titlePadding: AppStyle.edgeInsetsA24.copyWith(left: 48.w, right: 48.w),
contentPadding:
AppStyle.edgeInsetsA24.copyWith(left: 48.w, right: 48.w),
insetPadding: AppStyle.edgeInsetsA16,
actionsPadding: AppStyle.edgeInsetsA16,
surfaceTintColor: Colors.transparent,
backgroundColor: Get.theme.cardColor,
title: Text(
title,
style: AppStyle.titleStyleWhite,
),
content: Padding(
padding: AppStyle.edgeInsetsV12,
child: selectable ? SelectableText(content) : Text(content),
child: selectable
? SelectableText(
content,
style: AppStyle.textStyleWhite,
)
: Text(
content,
style: AppStyle.textStyleWhite,
),
),
actions: [
TextButton(
onPressed: (() => Get.back(result: false)),
child: Text(cancel.isEmpty ? "取消" : cancel),
child: Text(
cancel.isEmpty ? "取消" : cancel,
style: AppStyle.textStyleWhite,
),
),
TextButton(
autofocus: true,
onPressed: (() => Get.back(result: true)),
child: Text(confirm.isEmpty ? "确定" : confirm),
child: Text(
confirm.isEmpty ? "确定" : confirm,
style: AppStyle.textStyleWhite,
),
),
...?actions,
],
Expand Down
72 changes: 72 additions & 0 deletions simple_live_tv_app/lib/modules/category/category_controller.dart
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 simple_live_tv_app/lib/modules/category/category_page.dart
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,
),
),
);
}
}
Loading

0 comments on commit 15ce795

Please sign in to comment.