From f50ea21499b8271352d07d2ff828057177f06e70 Mon Sep 17 00:00:00 2001 From: Jordan Petridis Date: Wed, 23 Oct 2019 20:42:05 +0300 Subject: [PATCH] wip --- podcasts-gtk/src/stacks/main_stack.rs | 89 +++++++++++++++++++++++++++ 1 file changed, 89 insertions(+) create mode 100644 podcasts-gtk/src/stacks/main_stack.rs diff --git a/podcasts-gtk/src/stacks/main_stack.rs b/podcasts-gtk/src/stacks/main_stack.rs new file mode 100644 index 0000000..2b05c94 --- /dev/null +++ b/podcasts-gtk/src/stacks/main_stack.rs @@ -0,0 +1,89 @@ +// main_stack.rs +// +// Copyright 2019 Jordan Petridis +// +// This program is free software: you can redistribute it and/or modify +// it under the terms of the GNU General Public License as published by +// the Free Software Foundation, either version 3 of the License, or +// (at your option) any later version. +// +// This program is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +// GNU General Public License for more details. +// +// You should have received a copy of the GNU General Public License +// along with this program. If not, see . +// +// SPDX-License-Identifier: GPL-3.0-or-later + +#![allow(unused)] + +use crossbeam_channel::Sender; +use failure::Error; + +use crate::app::Action; + +use std::cell::RefCell; +use std::rc::Rc; + +use crate::i18n::i18n; + +use gtk::{self, prelude::*}; + +use crate:: widgets::{EpisodeWidget, EmptyView, ShowWidget, HomeView, ShowsView}; + +#[derive(Debug, Clone, Copy)] +pub (crate) enum State { + Empty, // Empty view in case you are not subbed into any shows + Home, // ListBox with the latests episodes + ShowsFlwobox, // Flowbox to browse all the shows you are subbed + ShowDetails, // 2 States, either empty or episodes list + EpisodeDetails, // WebView that shows the html description + DisoverView, // Way into the future view ?? +} + +struct StackWrapper { + state: State, + stack: gtk::Stack, +} + +pub struct PodcastsStack { + sender: Sender, + stack: StackWrapper, + empty_view: Rc, + home: Rc, + shows_flowbox: Rc, + show_details: Rc, + // episdoe: Rc, + // discover: unimplemented!(), +} + +impl PodcastsStack { + fn new(sender: Sender) -> Self { + let stack = StackWrapper { + state: State::Empty, + stack: gtk::Stack::new(), + }; + + let empty = Rc::new(EmptyView::default()); + let home = HomeView::new(sender.clone(), None).expect("Could not create a HomeView"); + let shows = ShowsView::new(sender.clone(), None); + let show = Rc::new(ShowWidget::default()); + // let episode = EpisodeDetails::default(); + + // stack.add_titled(&home.borrow().get_stack(), "home", &i18n("New")); + // stack.add_titled(&shows.borrow().get_stack(), "shows", &i18n("Shows")); + + PodcastsStack { + sender, + stack, + empty_view: empty, + home, + shows_flowbox: shows, + show_details: show, + } + } +} + +