mirror of
				https://github.com/yattee/yattee.git
				synced 2025-11-04 06:32:03 +00:00 
			
		
		
		
	Merge pull request #704 from patelhiren/subscriptions-account-picker
tvOS: Allow account picker by long pressing channels button in subscriptions view
This commit is contained in:
		@@ -11,6 +11,7 @@ struct FeedView: View {
 | 
				
			|||||||
 | 
					
 | 
				
			||||||
    #if os(tvOS)
 | 
					    #if os(tvOS)
 | 
				
			||||||
        @Default(.subscriptionsListingStyle) private var subscriptionsListingStyle
 | 
					        @Default(.subscriptionsListingStyle) private var subscriptionsListingStyle
 | 
				
			||||||
 | 
					        @StateObject private var accountsModel = AccountsViewModel()
 | 
				
			||||||
    #endif
 | 
					    #endif
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    var videos: [ContentItem] {
 | 
					    var videos: [ContentItem] {
 | 
				
			||||||
@@ -78,6 +79,23 @@ struct FeedView: View {
 | 
				
			|||||||
    }
 | 
					    }
 | 
				
			||||||
    
 | 
					    
 | 
				
			||||||
    #if os(tvOS)
 | 
					    #if os(tvOS)
 | 
				
			||||||
 | 
					    
 | 
				
			||||||
 | 
					    var accountsPicker: some View {
 | 
				
			||||||
 | 
					        ForEach(accountsModel.sortedAccounts.filter{ $0.anonymous == false }) { account in
 | 
				
			||||||
 | 
					            Button(action: {
 | 
				
			||||||
 | 
					                AccountsModel.shared.setCurrent(account)
 | 
				
			||||||
 | 
					            }) {
 | 
				
			||||||
 | 
					                HStack {
 | 
				
			||||||
 | 
					                    Text("\(account.description) (\(account.instance.app.rawValue))")
 | 
				
			||||||
 | 
					                    if account == accountsModel.currentAccount {
 | 
				
			||||||
 | 
					                        Image(systemName: "checkmark")
 | 
				
			||||||
 | 
					                    }
 | 
				
			||||||
 | 
					                }
 | 
				
			||||||
 | 
					            }
 | 
				
			||||||
 | 
					            .buttonStyle(PlainButtonStyle())
 | 
				
			||||||
 | 
					        }
 | 
				
			||||||
 | 
					    }
 | 
				
			||||||
 | 
					    
 | 
				
			||||||
    var feedChannelsView: some View {
 | 
					    var feedChannelsView: some View {
 | 
				
			||||||
        ScrollViewReader { proxy in
 | 
					        ScrollViewReader { proxy in
 | 
				
			||||||
            VStack {
 | 
					            VStack {
 | 
				
			||||||
@@ -198,19 +216,23 @@ struct FeedView: View {
 | 
				
			|||||||
    var header: some View {
 | 
					    var header: some View {
 | 
				
			||||||
        HStack(spacing: 16) {
 | 
					        HStack(spacing: 16) {
 | 
				
			||||||
            #if os(tvOS)
 | 
					            #if os(tvOS)
 | 
				
			||||||
                Button(action: {
 | 
					                if #available(tvOS 17.0, *) {
 | 
				
			||||||
                    withAnimation {
 | 
					                    Menu {
 | 
				
			||||||
                        self.feedChannelsViewVisible = true
 | 
					                        accountsPicker
 | 
				
			||||||
                        self.focusedChannel = selectedChannel?.id ?? "all"
 | 
					                    } label: {
 | 
				
			||||||
 | 
					                        Label("Channels", systemImage: "filemenu.and.selection")
 | 
				
			||||||
 | 
					                            .labelStyle(.iconOnly)
 | 
				
			||||||
 | 
					                            .imageScale(.small)
 | 
				
			||||||
 | 
					                            .font(.caption)
 | 
				
			||||||
 | 
					                    } primaryAction: {
 | 
				
			||||||
 | 
					                        withAnimation {
 | 
				
			||||||
 | 
					                            self.feedChannelsViewVisible = true
 | 
				
			||||||
 | 
					                            self.focusedChannel = selectedChannel?.id ?? "all"
 | 
				
			||||||
 | 
					                        }
 | 
				
			||||||
                    }
 | 
					                    }
 | 
				
			||||||
                }) {
 | 
					                    .opacity(feedChannelsViewVisible ? 0 : 1)
 | 
				
			||||||
                    Label("Channels", systemImage: "filemenu.and.selection")
 | 
					                    .frame(minWidth: feedChannelsViewVisible ? 0 : nil, maxWidth: feedChannelsViewVisible ? 0 : nil)
 | 
				
			||||||
                        .labelStyle(.iconOnly)
 | 
					 | 
				
			||||||
                        .imageScale(.small)
 | 
					 | 
				
			||||||
                        .font(.caption)
 | 
					 | 
				
			||||||
                }
 | 
					                }
 | 
				
			||||||
                .opacity(feedChannelsViewVisible ? 0 : 1)
 | 
					 | 
				
			||||||
                .frame(minWidth: feedChannelsViewVisible ? 0 : nil, maxWidth: feedChannelsViewVisible ? 0 : nil)
 | 
					 | 
				
			||||||
                channelHeaderView
 | 
					                channelHeaderView
 | 
				
			||||||
                if selectedChannel == nil {
 | 
					                if selectedChannel == nil {
 | 
				
			||||||
                    Spacer()
 | 
					                    Spacer()
 | 
				
			||||||
 
 | 
				
			|||||||
		Reference in New Issue
	
	Block a user