diff --git a/playlet-lib/src/components/ContentNode/BackendTypeContentNode.xml b/playlet-lib/src/components/ContentNode/BackendTypeContentNode.xml new file mode 100644 index 00000000..1c9cf635 --- /dev/null +++ b/playlet-lib/src/components/ContentNode/BackendTypeContentNode.xml @@ -0,0 +1,5 @@ + + + + + \ No newline at end of file diff --git a/playlet-lib/src/components/Screens/ProfileScreen/BackendTypeSelectionView/BackendTypeRowListCell.bs b/playlet-lib/src/components/Screens/ProfileScreen/BackendTypeSelectionView/BackendTypeRowListCell.bs new file mode 100644 index 00000000..6e390254 --- /dev/null +++ b/playlet-lib/src/components/Screens/ProfileScreen/BackendTypeSelectionView/BackendTypeRowListCell.bs @@ -0,0 +1,9 @@ +function OnContentSet() as void + content = m.top.itemContent + if content = invalid + return + end if + + m.top.backendName = content.title + m.top.backendLogoUri = content.backendLogoUri +end function diff --git a/playlet-lib/src/components/Screens/ProfileScreen/BackendTypeSelectionView/BackendTypeRowListCell.xml b/playlet-lib/src/components/Screens/ProfileScreen/BackendTypeSelectionView/BackendTypeRowListCell.xml new file mode 100644 index 00000000..3f43221a --- /dev/null +++ b/playlet-lib/src/components/Screens/ProfileScreen/BackendTypeSelectionView/BackendTypeRowListCell.xml @@ -0,0 +1,24 @@ + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/playlet-lib/src/components/Screens/ProfileScreen/BackendTypeSelectionView/BackendTypeSelectionView.bs b/playlet-lib/src/components/Screens/ProfileScreen/BackendTypeSelectionView/BackendTypeSelectionView.bs new file mode 100644 index 00000000..23da5d4e --- /dev/null +++ b/playlet-lib/src/components/Screens/ProfileScreen/BackendTypeSelectionView/BackendTypeSelectionView.bs @@ -0,0 +1,57 @@ +import "pkg:/components/Navigation/Navigation.bs" +import "pkg:/components/parts/AutoBind/OnNodeReadyNoOp.bs" +import "pkg:/source/utils/FocusManagement.bs" +import "pkg:/source/utils/Logging.bs" +import "pkg:/source/utils/RemoteKeys.bs" +import "pkg:/source/utils/Types.bs" + +function Init() + m.rowList = m.top.FindNode("BackendRowList") + m.rowList.ObserveField("rowItemSelected", FuncName(OnRowItemSelected)) +end function + +function OnFocusChange() as void + if not m.top.focus + return + end if + + NodeSetFocus(m.rowList, true) +end function + +function OnKeyEvent(key as string, press as boolean) as boolean + if key = RemoteKeys.Options or key = RemoteKeys.Play or key = RemoteKeys.Pause or key = RemoteKeys.PlayOnly + ' A pass-through to the app controller, so it can toggle picture-in-picture and pause/play + return false + end if + + if key = RemoteKeys.Back and press + Close() + return true + end if + + return true +end function + +function Close() + m.top.appController@.PopScreen() +end function + +function OnRowItemSelected(event as object) as void + index = event.GetData() + if index = invalid or index.count() <> 2 + LogWarn("Invalid index:", index) + return + end if + + Close() + + content = m.rowList.content + + rowIndex = index[0] + rowItemIndex = index[1] + + row = content.GetChild(rowIndex) + rowItem = row.GetChild(rowItemIndex) + + m.top.selectedBackendType = rowItem.id +end function diff --git a/playlet-lib/src/components/Screens/ProfileScreen/BackendTypeSelectionView/BackendTypeSelectionView.xml b/playlet-lib/src/components/Screens/ProfileScreen/BackendTypeSelectionView/BackendTypeSelectionView.xml new file mode 100644 index 00000000..105dc5d8 --- /dev/null +++ b/playlet-lib/src/components/Screens/ProfileScreen/BackendTypeSelectionView/BackendTypeSelectionView.xml @@ -0,0 +1,46 @@ + + + + + + + + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/playlet-lib/src/components/Screens/ProfileScreen/BackendTypeSelectionView/BackendTypeSelectionViewUtils.bs b/playlet-lib/src/components/Screens/ProfileScreen/BackendTypeSelectionView/BackendTypeSelectionViewUtils.bs new file mode 100644 index 00000000..c84de572 --- /dev/null +++ b/playlet-lib/src/components/Screens/ProfileScreen/BackendTypeSelectionView/BackendTypeSelectionViewUtils.bs @@ -0,0 +1,11 @@ +namespace BackendTypeSelectionViewUtils + + function Open(appController as object) as object + backendTypeSelectionView = CreateObject("roSGNode", "BackendTypeSelectionView") + + appController@.PushScreen(backendTypeSelectionView) + backendTypeSelectionView@.BindNode() + return backendTypeSelectionView + end function + +end namespace diff --git a/playlet-lib/src/components/Screens/ProfileScreen/ProfileRowList/ProfileRowList.xml b/playlet-lib/src/components/Screens/ProfileScreen/ProfileRowList/ProfileRowList.xml deleted file mode 100644 index fe1d56ab..00000000 --- a/playlet-lib/src/components/Screens/ProfileScreen/ProfileRowList/ProfileRowList.xml +++ /dev/null @@ -1,2 +0,0 @@ - - \ No newline at end of file diff --git a/playlet-lib/src/components/Screens/ProfileScreen/ProfileScreen.bs b/playlet-lib/src/components/Screens/ProfileScreen/ProfileScreen.bs index 6a801f1a..de150735 100644 --- a/playlet-lib/src/components/Screens/ProfileScreen/ProfileScreen.bs +++ b/playlet-lib/src/components/Screens/ProfileScreen/ProfileScreen.bs @@ -1,7 +1,9 @@ import "pkg:/components/Dialog/DialogUtils.bs" import "pkg:/components/Navigation/Navigation.bs" -import "pkg:/components/ProfileView/ProfileViewUtils.bs" +import "pkg:/components/Screens/ProfileScreen/BackendTypeSelectionView/BackendTypeSelectionViewUtils.bs" +import "pkg:/components/Screens/ProfileScreen/ProfileView/ProfileViewUtils.bs" import "pkg:/source/utils/FocusManagement.bs" +import "pkg:/source/utils/Logging.bs" import "pkg:/source/utils/RemoteKeys.bs" import "pkg:/source/utils/Types.bs" @@ -38,26 +40,58 @@ function OnRowItemSelected() as void row = m.profileRowList.content.GetChild(0) selectedProfile = row.GetChild(index) if selectedProfile.type = "login" - invidiousInstance = m.preferences["invidious.instance"] - if StringUtils.IsNullOrEmpty(invidiousInstance) - DialogUtils.ShowDialogEx({ - title: "No Invidious Instance" - message: [ - "Playlet built-in backend does not support login yet.", - "Can only login if an Invidious instance is set in the settings." - ] - }) + #if YT_OAUTH_SUPPORT + backendTypeSelectionView = BackendTypeSelectionViewUtils.Open(m.appController) + backendTypeSelectionView.observeFieldScoped("selectedBackendType", FuncName(OnBackEndSelected)) return - end if - dialog = CreateObject("roSGNode", "LoginDialog") - dialog@.BindNode() - m.top.getScene().dialog = dialog - return + #else + LoginWithInvidious() + return + #end if end if ProfileViewUtils.Open(selectedProfile, m.appController) end function +function OnBackEndSelected(event as object) as void + backendTypeSelectionView = event.GetRoSGNode() + backendTypeSelectionView.unobserveFieldScoped("selectedBackendType") + + selectedBackendType = event.getData() + if selectedBackendType = "BackendTypeInvidious" + LoginWithInvidious() + else if selectedBackendType = "BackendTypeYouTube" + LoginWithYouTube() + else + LogError("Unknown backend type:", selectedBackendType) + end if +end function + +function LoginWithInvidious() as void + invidiousInstance = m.preferences["invidious.instance"] + if StringUtils.IsNullOrEmpty(invidiousInstance) + DialogUtils.ShowDialogEx({ + title: "No Invidious Instance" + message: [ + "Playlet built-in backend does not support login yet.", + "Can only login if an Invidious instance is set in the settings." + ] + }) + return + end if + + dialog = CreateObject("roSGNode", "LoginDialog") + dialog@.BindNode() + m.top.getScene().dialog = dialog +end function + +function LoginWithYouTube() as void + DialogUtils.ShowDialogEx({ + title: "YouTube" + message: ["Not implemented yet."] + }) +end function + function OnCurrentProfileChanged() as void currentProfile = m.profilesService.currentProfile if currentProfile = invalid diff --git a/playlet-lib/src/components/Screens/ProfileScreen/ProfileScreen.xml b/playlet-lib/src/components/Screens/ProfileScreen/ProfileScreen.xml index 8d4c6ab5..1fe007dc 100644 --- a/playlet-lib/src/components/Screens/ProfileScreen/ProfileScreen.xml +++ b/playlet-lib/src/components/Screens/ProfileScreen/ProfileScreen.xml @@ -7,7 +7,7 @@ - + + + + + + + + + \ No newline at end of file diff --git a/playlet-lib/src/images/invidious-logo.svg.meta.json5 b/playlet-lib/src/images/invidious-logo.svg.meta.json5 new file mode 100644 index 00000000..4484ad7f --- /dev/null +++ b/playlet-lib/src/images/invidious-logo.svg.meta.json5 @@ -0,0 +1,11 @@ +{ + inputHash: '339be7a03116276ba83ce7b1bb905e40', + outputs: [ + { + outputFilePath: 'images/invidious-logo.png', + outputHash: '31fcb0fb5d7506ba6e742a31497ca052', + width: 256, + height: 256, + }, + ], +} \ No newline at end of file diff --git a/playlet-lib/src/images/youtube-logo.png b/playlet-lib/src/images/youtube-logo.png new file mode 100644 index 00000000..5a831141 Binary files /dev/null and b/playlet-lib/src/images/youtube-logo.png differ diff --git a/playlet-lib/src/images/youtube-logo.svg b/playlet-lib/src/images/youtube-logo.svg new file mode 100644 index 00000000..95326245 --- /dev/null +++ b/playlet-lib/src/images/youtube-logo.svg @@ -0,0 +1,15 @@ + \ No newline at end of file diff --git a/playlet-lib/src/images/youtube-logo.svg.meta.json5 b/playlet-lib/src/images/youtube-logo.svg.meta.json5 new file mode 100644 index 00000000..c1154365 --- /dev/null +++ b/playlet-lib/src/images/youtube-logo.svg.meta.json5 @@ -0,0 +1,11 @@ +{ + inputHash: '38d7d7e95f79456ccb7a29aef004dd73', + outputs: [ + { + outputFilePath: 'images/youtube-logo.png', + outputHash: 'a015e471b97c7ffbbd012b4c9b9e0624', + width: 256, + height: 256, + }, + ], +} \ No newline at end of file diff --git a/playlet-lib/src/manifest b/playlet-lib/src/manifest index 02946a83..8c2d9ac6 100644 --- a/playlet-lib/src/manifest +++ b/playlet-lib/src/manifest @@ -13,4 +13,4 @@ hidden=1 git_commit_sha=unknown -bs_const=DEBUG=false \ No newline at end of file +bs_const=DEBUG=false;YT_OAUTH_SUPPORT=false