Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
  • Loading branch information
xiaoyaocz committed Sep 13, 2023
2 parents a301913 + 4364c39 commit 88ac158
Show file tree
Hide file tree
Showing 31 changed files with 695 additions and 182 deletions.
6 changes: 3 additions & 3 deletions assets/app_version.json
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
{
"version": "1.3.0",
"version_num": 10300,
"version_desc": "1. 优化播放器 #78,#113\n2. 支持画面尺寸调整 #61\n3. 支持锁定播放器 #53\n4. 取消关注增加提示框 #120\n5. 修复抖音直播问题 #121\n6. 优化哔哩哔哩直播弹幕获取\n7. 播放器支持截图",
"version": "1.3.1",
"version_num": 10301,
"version_desc": "1. 支持直播间内设置定时关闭 #124\n2. 支持主页与平台自定义排序 #16,#76\n3. 支持跳转至原APP中打开直播间 #118\n4. 斗鱼增加录播判断 #6,#103\n5. 修复抖音直播问题 #121\n6. 播放失败尝试自动重连",
"prerelease":false,
"download_url": "https://github.com/xiaoyaocz/dart_simple_live/releases"
}
1 change: 1 addition & 0 deletions simple_live_app/android/app/src/main/AndroidManifest.xml
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
<uses-permission android:name="android.permission.INTERNET" />
<uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE"/>
<uses-permission android:name="android.permission.READ_EXTERNAL_STORAGE"/>
<uses-permission android:name="android.permission.MANAGE_EXTERNAL_STORAGE" />
<application
android:label="Simple Live"
android:name="${applicationName}"
Expand Down
37 changes: 37 additions & 0 deletions simple_live_app/lib/app/constant.dart
Original file line number Diff line number Diff line change
@@ -1,3 +1,40 @@
import 'package:flutter/material.dart';
import 'package:remixicon/remixicon.dart';

class Constant {
static const String kUpdateFollow = "UpdateFollow";

static final Map<String, HomePageItem> allHomePages = {
"recommend": HomePageItem(
iconData: Remix.home_smile_line,
title: "首页",
index: 0,
),
"follow": HomePageItem(
iconData: Remix.heart_line,
title: "关注",
index: 1,
),
"category": HomePageItem(
iconData: Remix.apps_line,
title: "分类",
index: 2,
),
"user": HomePageItem(
iconData: Remix.user_smile_line,
title: "我的",
index: 3,
),
};
}

class HomePageItem {
final IconData iconData;
final String title;
final int index;
HomePageItem({
required this.iconData,
required this.title,
required this.index,
});
}
62 changes: 62 additions & 0 deletions simple_live_app/lib/app/controller/app_settings_controller.dart
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
import 'package:simple_live_app/app/constant.dart';
import 'package:simple_live_app/app/sites.dart';
import 'package:simple_live_app/services/local_storage_service.dart';

import 'package:flutter/material.dart';
Expand Down Expand Up @@ -63,9 +65,51 @@ class AppSettingsController extends GetxController {
0,
);

initSiteSort();
initHomeSort();
super.onInit();
}

void initSiteSort() {
var sort = LocalStorageService.instance
.getValue(
LocalStorageService.kSiteSort,
Sites.allSites.keys.join(","),
)
.split(",");
//如果数量与allSites的数量不一致,将缺失的添加上
if (sort.length != Sites.allSites.length) {
var keys = Sites.allSites.keys.toList();
for (var i = 0; i < keys.length; i++) {
if (!sort.contains(keys[i])) {
sort.add(keys[i]);
}
}
}

siteSort.value = sort;
}

void initHomeSort() {
var sort = LocalStorageService.instance
.getValue(
LocalStorageService.kHomeSort,
Constant.allHomePages.keys.join(","),
)
.split(",");
//如果数量与allSites的数量不一致,将缺失的添加上
if (sort.length != Constant.allHomePages.length) {
var keys = Constant.allHomePages.keys.toList();
for (var i = 0; i < keys.length; i++) {
if (!sort.contains(keys[i])) {
sort.add(keys[i]);
}
}
}

homeSort.value = sort;
}

void setNoFirstRun() {
LocalStorageService.instance.setValue(LocalStorageService.kFirstRun, false);
}
Expand Down Expand Up @@ -224,4 +268,22 @@ class AppSettingsController extends GetxController {
value,
);
}

RxList<String> siteSort = RxList<String>();
void setSiteSort(List<String> e) {
siteSort.value = e;
LocalStorageService.instance.setValue(
LocalStorageService.kSiteSort,
siteSort.join(","),
);
}

RxList<String> homeSort = RxList<String>();
void setHomeSort(List<String> e) {
homeSort.value = e;
LocalStorageService.instance.setValue(
LocalStorageService.kHomeSort,
homeSort.join(","),
);
}
}
19 changes: 13 additions & 6 deletions simple_live_app/lib/app/sites.dart
Original file line number Diff line number Diff line change
@@ -1,32 +1,39 @@
import 'package:simple_live_app/app/controller/app_settings_controller.dart';
import 'package:simple_live_core/simple_live_core.dart';

class Sites {
static List<Site> supportSites = [
Site(
static final Map<String, Site> allSites = {
"bilibili": Site(
id: "bilibili",
logo: "assets/images/bilibili_2.png",
name: "哔哩哔哩",
liveSite: BiliBiliSite(),
),
Site(
"douyu": Site(
id: "douyu",
logo: "assets/images/douyu.png",
name: "斗鱼直播",
liveSite: DouyuSite(),
),
Site(
"huya": Site(
id: "huya",
logo: "assets/images/huya.png",
name: "虎牙直播",
liveSite: HuyaSite(),
),
Site(
"douyin": Site(
id: "douyin",
logo: "assets/images/douyin.png",
name: "抖音直播",
liveSite: DouyinSite(),
),
];
};

static List<Site> get supportSites {
return AppSettingsController.instance.siteSort
.map((key) => allSites[key]!)
.toList();
}
}

class Site {
Expand Down
33 changes: 33 additions & 0 deletions simple_live_app/lib/app/utils.dart
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
import 'dart:io';

import 'package:device_info_plus/device_info_plus.dart';
import 'package:flutter/services.dart';
import 'package:flutter_smart_dialog/flutter_smart_dialog.dart';
import 'package:permission_handler/permission_handler.dart';
Expand Down Expand Up @@ -443,6 +444,38 @@ class Utils {
}
}

static final DeviceInfoPlugin deviceInfo = DeviceInfoPlugin();

/// 检查文件权限
static Future<bool> checkStorgePermission() async {
try {
if (!Platform.isAndroid) {
return true;
}
Permission permission = Permission.storage;
var androidIndo = await deviceInfo.androidInfo;
if (androidIndo.version.sdkInt >= 33) {
permission = Permission.manageExternalStorage;
}

var status = await permission.status;
if (status == PermissionStatus.granted) {
return true;
}
status = await permission.request();
if (status.isGranted) {
return true;
} else {
SmartDialog.showToast(
"请授予文件访问权限",
);
return false;
}
} catch (e) {
return false;
}
}

///16进制颜色转换
static Color convertHexColor(String hexColor) {
hexColor = hexColor.replaceAll("#", "");
Expand Down
28 changes: 21 additions & 7 deletions simple_live_app/lib/modules/indexed/indexed_controller.dart
Original file line number Diff line number Diff line change
@@ -1,28 +1,36 @@
import 'package:flutter/widgets.dart';

import 'package:get/get.dart';
import 'package:simple_live_app/app/constant.dart';
import 'package:simple_live_app/app/controller/app_settings_controller.dart';
import 'package:simple_live_app/app/event_bus.dart';
import 'package:simple_live_app/app/utils.dart';
import 'package:simple_live_app/modules/category/category_controller.dart';
import 'package:simple_live_app/modules/category/category_page.dart';
import 'package:simple_live_app/modules/home/home_controller.dart';
import 'package:simple_live_app/modules/home/home_page.dart';
import 'package:simple_live_app/modules/user/follow_user/follow_user_controller.dart';
import 'package:simple_live_app/modules/user/follow_user/follow_user_page.dart';
import 'package:simple_live_app/modules/user/user_page.dart';

class IndexedController extends GetxController {
RxList<HomePageItem> items = RxList<HomePageItem>([]);

var index = 0.obs;
RxList<Widget> pages = RxList<Widget>([
const HomePage(),
const SizedBox(),
const SizedBox(),
const SizedBox(),
const SizedBox(),
]);

void setIndex(i) {
void setIndex(int i) {
if (pages[i] is SizedBox) {
switch (i) {
switch (items[i].index) {
case 0:
Get.put(HomeController());
pages[i] = const HomePage();
break;
case 1:
Get.put(FollowUserController());
pages[i] = const FollowUserPage();
Expand All @@ -31,22 +39,28 @@ class IndexedController extends GetxController {
Get.put(CategoryController());
pages[i] = const CategoryPage();
break;

case 3:
pages[i] = const UserPage();
break;
default:
}
} else {
if (index.value == i) {
EventBus.instance
.emit<int>(EventBus.kBottomNavigationBarClicked, items[i].index);
}
}
if (index.value == i) {
EventBus.instance.emit<int>(EventBus.kBottomNavigationBarClicked, i);
}

index.value = i;
}

@override
void onInit() {
Future.delayed(Duration.zero, showFirstRun);
items.value = AppSettingsController.instance.homeSort
.map((key) => Constant.allHomePages[key]!)
.toList();
setIndex(0);
super.onInit();
}

Expand Down
63 changes: 8 additions & 55 deletions simple_live_app/lib/modules/indexed/indexed_page.dart
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
import 'package:flutter/material.dart';
import 'package:get/get.dart';
import 'package:remixicon/remixicon.dart';

import 'indexed_controller.dart';

Expand All @@ -22,62 +21,16 @@ class IndexedPage extends GetView<IndexedController> {
onDestinationSelected: controller.setIndex,
height: 56,
labelBehavior: NavigationDestinationLabelBehavior.alwaysHide,
destinations: const [
NavigationDestination(
icon: Icon(Remix.home_smile_line),
label: "首页",
),
NavigationDestination(
icon: Icon(Remix.heart_line),
label: "关注",
),
NavigationDestination(
icon: Icon(Remix.apps_line),
label: "分类",
),
NavigationDestination(
icon: Icon(Remix.user_smile_line),
label: "我的",
),
],
destinations: controller.items
.map(
(item) => NavigationDestination(
icon: Icon(item.iconData),
label: item.title,
),
)
.toList(),
),
),
// bottomNavigationBar: Obx(
// () => BottomNavigationBar(
// currentIndex: controller.index.value,
// onTap: controller.setIndex,
// selectedFontSize: 12,
// unselectedFontSize: 12,
// iconSize: 24,
// type: BottomNavigationBarType.fixed,
// showSelectedLabels: true,
// showUnselectedLabels: true,
// elevation: 4,
// landscapeLayout: BottomNavigationBarLandscapeLayout.centered,
// items: const [
// BottomNavigationBarItem(
// icon: Icon(Remix.home_smile_line),
// activeIcon: Icon(Remix.home_smile_fill),
// label: "首页",
// ),
// BottomNavigationBarItem(
// icon: Icon(Remix.apps_line),
// activeIcon: Icon(Remix.apps_fill),
// label: "分类",
// ),
// BottomNavigationBarItem(
// icon: Icon(Remix.tools_line),
// activeIcon: Icon(Remix.tools_fill),
// label: "工具箱",
// ),
// BottomNavigationBarItem(
// icon: Icon(Remix.user_smile_line),
// activeIcon: Icon(Remix.user_smile_fill),
// label: "我的",
// ),
// ],
// ),
// ),
);
}
}
Loading

0 comments on commit 88ac158

Please sign in to comment.