Skip to content
New issue

Have a question about this project? # for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “#”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? # to your account

Add share dialog with clipboard #277

Merged
merged 4 commits into from
Jan 31, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions .gitmodules
Original file line number Diff line number Diff line change
Expand Up @@ -25,3 +25,6 @@
[submodule "library/MemoryModule"]
path = library/MemoryModule
url = https://github.com/fancycode/MemoryModule.git
[submodule "library/clip"]
path = library/clip
url = https://github.com/dacap/clip.git
2 changes: 2 additions & 0 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -231,6 +231,8 @@ if (PLATFORM_DESKTOP)
"${CMAKE_CURRENT_SOURCE_DIR}/scripts/linux/${PACKAGE_NAME}.appdata.xml"
"${CMAKE_CURRENT_SOURCE_DIR}/scripts/linux/${PACKAGE_NAME}.desktop")
endif ()

list(APPEND APP_PLATFORM_LIB clip)
elseif (PLATFORM_IOS)
ios_bundle(
"${CMAKE_CURRENT_SOURCE_DIR}/library/borealis/demo/ios/tvos/Splash.storyboard"
Expand Down
8 changes: 8 additions & 0 deletions library/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -84,6 +84,14 @@ set(BUILD_SHARED_LIBS OFF)
set(CMAKE_POLICY_DEFAULT_CMP0077 NEW)
add_subdirectory(lunasvg EXCLUDE_FROM_ALL)

# add dacap
if (PLATFORM_DESKTOP)
set(CLIP_EXAMPLES OFF)
set(CLIP_TESTS OFF)
add_subdirectory(clip EXCLUDE_FROM_ALL)
target_include_directories(clip PUBLIC ${CMAKE_CURRENT_SOURCE_DIR})
endif ()

# add mongoose
if (USE_SYSTEM_MONGOOSE)
find_library(MONGOOSE_LIBRARY NAMES mongoose REQUIRED)
Expand Down
1 change: 1 addition & 0 deletions library/clip
Submodule clip added at 94693e
1 change: 1 addition & 0 deletions resources/i18n/en-US/wiliwili.json
Original file line number Diff line number Diff line change
Expand Up @@ -276,6 +276,7 @@
"recommend": "Recommend",
"uploaded": "Others",
"qr": "Scan QR code to watch/share",
"clipboard": "Copied to clipboard",
"comment": "Comment",
"current": " people are watching",
"share": "Share",
Expand Down
1 change: 1 addition & 0 deletions resources/i18n/zh-Hans/wiliwili.json
Original file line number Diff line number Diff line change
Expand Up @@ -276,6 +276,7 @@
"recommend": "推荐",
"uploaded": "投稿",
"qr": "手机扫码观看/分享",
"clipboard": "已复制到剪贴板",
"comment": "评论",
"current": "人正在看",
"share": "分享",
Expand Down
1 change: 1 addition & 0 deletions resources/i18n/zh-Hant/wiliwili.json
Original file line number Diff line number Diff line change
Expand Up @@ -276,6 +276,7 @@
"recommend": "推薦",
"uploaded": "投稿",
"qr": "手機掃碼觀看/分享",
"clipboard": "已複製到剪貼板",
"comment": "評論",
"current": "人正在看",
"share": "分享",
Expand Down
9 changes: 9 additions & 0 deletions resources/svg/share-dynamic.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
6 changes: 6 additions & 0 deletions resources/svg/share-qq.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
7 changes: 7 additions & 0 deletions resources/svg/share-qzone.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
7 changes: 7 additions & 0 deletions resources/svg/share-tieba.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
7 changes: 7 additions & 0 deletions resources/svg/share-wechat.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
6 changes: 6 additions & 0 deletions resources/svg/share-weibo.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
13 changes: 13 additions & 0 deletions resources/xml/fragment/share_box.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
<brls:Box
axis="column"
alignItems="center"
padding="15">
<SVGImage
width="64"
height="64"
marginBottom="10"
id="share/image"/>
<brls:Label
fontSize="18"
id="share/title"/>
</brls:Box>
108 changes: 108 additions & 0 deletions resources/xml/fragment/share_dialog.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,108 @@
<brls:Box
padding="30"
justifyContent="center"
alignItems="center">

<ButtonClose
positionType="absolute"
positionTop="10"
positionRight="10" />

<brls:Box
axis="column"
alignItems="center"
margin="10">

<QRImage
width="220"
height="220"
margin="10"
focusable="true"
id="share/qrcode" />

<brls:Label
fontSize="18"
text="@i18n/wiliwili/player/qr" />
</brls:Box>

<brls:Box
axis="column"
grow="1.0"
lineColor="@theme/color/line"
lineLeft="2"
id="share/box"
marginLeft="25"
paddingLeft="20"
paddingRight="20">

<brls:Box
justifyContent="spaceBetween">
<ShareBox
title="QQ"
icon="@res/svg/share-qq.svg"
focusable="true"
focusUp="share/box/qq"
focusDown="share/box/tieba"
id="share/box/qq" />
<ShareBox
title="QQ空间"
icon="@res/svg/share-qzone.svg"
focusable="true"
focusUp="share/box/qzone"
focusDown="share/box/weibo"
id="share/box/qzone" />
<ShareBox
title="微信"
icon="@res/svg/share-wechat.svg"
focusable="true"
focusUp="share/box/wechat"
focusDown="share/box/dynamic"
action="clipboard"
id="share/box/wechat" />
</brls:Box>

<brls:Box
justifyContent="spaceBetween">
<ShareBox
title="贴吧"
icon="@res/svg/share-tieba.svg"
focusable="true"
focusUp="share/box/qq"
focusDown="share/box/tieba"
id="share/box/tieba" />
<ShareBox
title="微博"
icon="@res/svg/share-weibo.svg"
focusable="true"
focusUp="share/box/qzone"
focusDown="share/box/weibo"
id="share/box/weibo" />
<ShareBox
title="动态"
icon="@res/svg/share-dynamic.svg"
focusable="true"
focusUp="share/box/wechat"
focusDown="share/box/dynamic"
action="clipboard"
id="share/box/dynamic" />
</brls:Box>

</brls:Box>

<brls:Box
cornerRadius="4"
backgroundColor="@theme/brls/backdrop"
positionBottom="150"
positionLeft="300"
positionType="absolute"
justifyContent="center"
alignItems="center"
visibility="gone"
id="share/hint/box">
<brls:Label
margin="10"
textColor="#FFFFFF"
text="@i18n/wiliwili/player/clipboard" />
</brls:Box>

</brls:Box>
3 changes: 0 additions & 3 deletions wiliwili/include/activity/player_activity.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -50,9 +50,6 @@ class BasePlayerActivity : public brls::Activity, public VideoDetail {
// 设置 点赞、收藏、投币 三个按钮的样式
void setRelationButton(bool liked, bool coin, bool favorite);

// 展示二维码共享对话框
void showShareDialog(const std::string& link);

// 展示收藏列表对话框
void showCollectionDialog(int64_t id, int videoType);

Expand Down
4 changes: 4 additions & 0 deletions wiliwili/include/api/bilibili/result/home_pgc_season_result.h
Original file line number Diff line number Diff line change
Expand Up @@ -206,6 +206,7 @@ inline void from_json(const nlohmann::json& nlohmann_json_j, SeasonRecommendWrap
class SeasonResultWrapper {
public:
unsigned int season_id;
std::string cover;
std::string season_title;
std::string season_desc;
SeasonEpisodeListResult episodes;
Expand Down Expand Up @@ -257,6 +258,9 @@ inline void from_json(const nlohmann::json& nlohmann_json_j, SeasonResultWrapper
if (nlohmann_json_j.contains("user_status")) {
nlohmann_json_j.at("user_status").get_to(nlohmann_json_t.user_status);
}
if (nlohmann_json_j.contains("cover")) {
nlohmann_json_j.at("cover").get_to(nlohmann_json_t.cover);
}
NLOHMANN_JSON_EXPAND(NLOHMANN_JSON_PASTE(NLOHMANN_JSON_FROM, season_id, season_title, evaluate));
}

Expand Down
59 changes: 59 additions & 0 deletions wiliwili/include/fragment/share_dialog.hpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,59 @@
#pragma once

#include <borealis/core/box.hpp>
#include <borealis/core/bind.hpp>
#include <borealis/core/event.hpp>
#include <api/bilibili/result/video_detail_result.h>
#include <api/bilibili/result/home_pgc_season_result.h>

namespace brls {
class Label;
} // namespace brls

class SVGImage;
class QRImage;
class ButtonClose;
class ShareBox : public brls::Box {
public:
ShareBox();

void setLink(const std::string& value) { this->link = value; }

void setAction(const std::string& value) { this->action = value; }

brls::VoidEvent* getEvent() { return &this->eventClipboard; }

static View* create();

private:
BRLS_BIND(brls::Label, title, "share/title");
BRLS_BIND(SVGImage, image, "share/image");

std::string link;
std::string action;
brls::VoidEvent eventClipboard;
};

class ShareDialog : public brls::Box {
public:
ShareDialog();
~ShareDialog() override;

void open(const std::string& link);
void open(const bilibili::VideoDetailResult& result);
void open(const bilibili::SeasonEpisodeResult& result, const std::string& pics = "",
const std::string& summary = "");

private:
BRLS_BIND(QRImage, qrcode, "share/qrcode");
BRLS_BIND(brls::Box, boxShare, "share/box");
BRLS_BIND(brls::Box, boxHint, "share/hint/box");
BRLS_BIND(ShareBox, qq, "share/box/qq");
BRLS_BIND(ShareBox, qzone, "share/box/qzone");
BRLS_BIND(ShareBox, tieba, "share/box/tieba");
BRLS_BIND(ShareBox, wechat, "share/box/wechat");
BRLS_BIND(ShareBox, weibo, "share/box/weibo");
BRLS_BIND(ShareBox, dynamic, "share/box/dynamic");

void showHint();
};
Loading
Loading