Commit cc81e27c authored by Daniel Garcia Moreno's avatar Daniel Garcia Moreno

Merge branch 'mobile-ui' into 'master'

Basic Mobile UI

See merge request World/fractal!268
parents 0dfb8efa 78dc7593
Pipeline #40637 passed with stages
in 29 minutes and 41 seconds
......@@ -301,3 +301,8 @@ stack.titlebar:not(headerbar) > box > separator {
.small-font {
font-size: small;
}
box.folded-history > hdycolumn > list {
padding-left: 6px;
padding-right: 6px;
}
......@@ -2,6 +2,7 @@
<!-- Generated with glade 3.20.2 -->
<interface>
<requires lib="gtk+" version="3.20"/>
<requires lib="libhandy" version="0.0"/>
<object class="GtkApplicationWindow" id="main_window">
<property name="can_focus">False</property>
<property name="default_width">860</property>
......@@ -10,16 +11,22 @@
<child>
<object class="GtkStack" id="main_content_stack">
<property name="can_focus">False</property>
<property name="hhomogeneous">False</property>
<child>
<object class="GtkBox" id="chat_state">
<object class="HdyLeaflet" id="chat_state">
<property name="child-transition-duration" bind-source="header_leaflet" bind-property="child-transition-duration" bind-flags="bidirectional|sync-create"/>
<property name="child-transition-type" bind-source="header_leaflet" bind-property="child-transition-type" bind-flags="bidirectional|sync-create"/>
<property name="mode-transition-duration" bind-source="header_leaflet" bind-property="mode-transition-duration" bind-flags="bidirectional|sync-create"/>
<property name="mode-transition-type" bind-source="header_leaflet" bind-property="mode-transition-type" bind-flags="bidirectional|sync-create"/>
<property name="visible">True</property>
<property name="can_focus">False</property>
<property name="hhomogeneous-folded">True</property>
<child>
<object class="GtkBox" id="sidebar-box">
<property name="width_request">200</property>
<property name="visible">True</property>
<property name="can_focus">False</property>
<property name="halign">start</property>
<property name="halign">fill</property>
<property name="hexpand">False</property>
<property name="orientation">vertical</property>
<child>
......@@ -80,15 +87,16 @@
</child>
</object>
<packing>
<property name="expand">False</property>
<property name="fill">False</property>
<property name="position">0</property>
<property name="name">sidebar-box</property>
</packing>
</child>
<child>
<object class="GtkSeparator">
<object class="GtkSeparator" id="content_separator">
<property name="visible">True</property>
<property name="can_focus">False</property>
<style>
<class name="sidebar"/>
</style>
</object>
<packing>
<property name="expand">False</property>
......@@ -278,10 +286,7 @@
</child>
</object>
<packing>
<property name="expand">True</property>
<property name="fill">True</property>
<property name="pack_type">end</property>
<property name="position">0</property>
<property name="name">inapp</property>
</packing>
</child>
</object>
......@@ -730,14 +735,19 @@
<property name="visible">True</property>
<property name="can_focus">False</property>
<property name="hexpand">True</property>
<property name="hhomogeneous">False</property>
<child>
<object class="GtkBox"> <!--message view-->
<object class="HdyLeaflet" id="header_leaflet"> <!--message view-->
<property name="child-transition-type">slide</property>
<property name="mode-transition-type">slide</property>
<property name="visible">True</property>
<property name="hhomogeneous-folded">True</property>
<child>
<object class="GtkHeaderBar" id="left-header"> <!--left titlebar-->
<property name="visible">True</property>
<property name="can_focus">False</property>
<!--<property name="show-close-button">True</property>-->
<property name="halign">fill</property>
<property name="show-close-button">True</property>
<child>
<object class="GtkMenuButton" id="main_menu_button">
<property name="visible">True</property>
......@@ -819,9 +829,12 @@
</object>
</child>
</object>
<packing>
<property name="name">left-header</property>
</packing>
</child>
<child>
<object class="GtkSeparator">
<object class="GtkSeparator" id="header_separator">
<property name="visible">True</property>
<property name="can_focus">False</property>
<property name="orientation">vertical</property>
......@@ -835,6 +848,35 @@
<property name="show-close-button">True</property>
<property name="has-subtitle">False</property>
<property name="hexpand">True</property>
<child>
<object class="GtkRevealer">
<property name="reveal-child" bind-source="header_leaflet" bind-property="folded" bind-flags="sync-create"/>
<property name="transition-duration" bind-source="header_leaflet" bind-property="mode-transition-duration" bind-flags="bidirectional|sync-create"/>
<property name="transition-type">crossfade</property>
<property name="visible">True</property>
<child>
<object class="GtkButton" id="room_header_back_button">
<property name="receives-default">False</property>
<property name="visible">True</property>
<style>
<class name="image-button"/>
</style>
<child internal-child="accessible">
<object class="AtkObject">
<property name="accessible-name" translatable="yes">Back</property>
</object>
</child>
<child>
<object class="GtkImage">
<property name="icon-name">go-previous-symbolic</property>
<property name="icon-size">1</property>
<property name="visible">True</property>
</object>
</child>
</object>
</child>
</object>
</child>
<child type="title">
<object class="GtkBox" id="room_info">
<property name="visible">True</property>
......@@ -899,6 +941,9 @@
</packing>
</child>
</object>
<packing>
<property name="name">room_header_bar</property>
</packing>
</child>
</object>
<packing>
......@@ -1037,4 +1082,24 @@
<widget name="sidebar-box"/>
</widgets>
</object>
<object class="GtkSizeGroup">
<property name="mode">horizontal</property>
<widgets>
<widget name="room_header_bar"/>
<widget name="inapp"/>
</widgets>
</object>
<object class="GtkSizeGroup">
<property name="mode">horizontal</property>
<widgets>
<widget name="header_separator"/>
<widget name="content_separator"/>
</widgets>
</object>
<object class="HdyHeaderGroup">
<headerbars>
<headerbar name="left-header"/>
<headerbar name="room_header_bar"/>
</headerbars>
</object>
</interface>
......@@ -2,6 +2,7 @@ use app::App;
use appop::MsgPos;
use appop::AppState;
use appop::LeafletState;
use std::thread;
use std::sync::mpsc::Receiver;
......@@ -20,6 +21,7 @@ pub enum InternalCommand {
SetView(AppState),
NotifyClicked(Message),
SelectRoom(Room),
ShowRoomList,
LoadMore,
LoadMoreNormal,
RemoveInv(String),
......@@ -54,11 +56,15 @@ pub fn appop_loop(rx: Receiver<InternalCommand>) {
APPOP!(set_state, (view));
}
Ok(InternalCommand::NotifyClicked(msg)) => {
let state = LeafletState::Content;
APPOP!(notification_cliked, (msg));
APPOP!(set_leaflet_state, (state));
}
Ok(InternalCommand::SelectRoom(r)) => {
let id = r.id;
let state = LeafletState::Content;
APPOP!(set_active_room_by_id, (id));
APPOP!(set_leaflet_state, (state));
}
Ok(InternalCommand::LoadMore) => {
APPOP!(load_more_messages);
......@@ -84,6 +90,10 @@ pub fn appop_loop(rx: Receiver<InternalCommand>) {
Ok(InternalCommand::PurchaseSticker(group)) => {
APPOP!(purchase_sticker, (group));
}
Ok(InternalCommand::ShowRoomList) => {
let state = LeafletState::Sidebar;
APPOP!(set_leaflet_state, (state));
}
Err(_) => {
break;
}
......
......@@ -4,6 +4,9 @@ use gtk::prelude::*;
use appop::AppState;
use app::App;
use app::InternalCommand;
use std::sync::Arc;
impl App {
pub fn connect_headerbars(&self) {
......@@ -14,6 +17,17 @@ impl App {
btn.connect_clicked(move |_| {
op.lock().unwrap().set_state(AppState::Chat);
});
let back_btn = self.ui.builder
.get_object::<gtk::Button>("room_header_back_button")
.expect("Can't find room_header_back_button in ui file.");
let weak_op = Arc::downgrade(&self.op);
back_btn.connect_clicked(move |_| {
weak_op.upgrade().map(|op| {
op.lock().unwrap().internal.send(InternalCommand::ShowRoomList)
.unwrap();
});
});
if let Some(set) = gtk::Settings::get_default() {
let left_header: gtk::HeaderBar = self.ui.builder
......
use gtk::{self, prelude::*};
use libhandy::*;
use app::App;
impl App {
pub fn connect_leaflet(&self) {
let container = self.ui.builder
.get_object::<gtk::Box>("message_column")
.expect("Can't find message_column in ui file.");
let chat_state_leaflet: libhandy::Leaflet = self.ui.builder
.get_object("chat_state")
.expect("Can't find chat_state in ui file.");
let weak_container = container.downgrade();
chat_state_leaflet.connect_property_fold_notify(move |leaflet| {
weak_container.upgrade().map(|container| {
match leaflet.get_fold() {
Fold::Folded => container.get_style_context().unwrap().add_class("folded-history"),
Fold::Unfolded => container.get_style_context().unwrap().remove_class("folded-history"),
_ => ()
}
});
});
}
}
......@@ -10,6 +10,7 @@ mod directory;
mod headerbar;
mod invite;
mod join_room;
mod leaflet;
mod leave_room;
mod login;
mod markdown;
......@@ -61,6 +62,8 @@ impl App {
self.connect_headerbars();
self.connect_login_view();
self.connect_leaflet();
self.connect_send();
self.connect_attach();
self.connect_markdown();
......
......@@ -65,6 +65,8 @@ impl App {
let gtk_app = gtk::Application::new(Some(&appid[..]), gio::ApplicationFlags::empty())
.expect("Failed to initialize GtkApplication");
libhandy::Leaflet::get_type(&libhandy::Leaflet::new());
gtk_app.set_accels_for_action("app.quit", &["<Ctrl>Q"]);
let path = "/org/gnome/Fractal".to_string();
......
use libhandy::*;
use appop::AppOp;
use appop::RoomPanel;
#[derive(Clone, Debug)]
pub enum LeafletState {
Content,
Sidebar
}
impl AppOp {
pub fn set_leaflet_state(&mut self, state: LeafletState) {
match state {
LeafletState::Content => {
self.header_leaflet.set_visible_child_name("room_header_bar");
self.chat_state.set_visible_child_name("inapp");
},
LeafletState::Sidebar => {
self.room_panel(RoomPanel::NoRoom);
self.active_room = None;
self.header_leaflet.set_visible_child_name("left-header");
self.chat_state.set_visible_child_name("sidebar-box");
}
}
}
}
......@@ -5,6 +5,8 @@ use gio::ApplicationExt;
use gtk;
use gtk::prelude::*;
use libhandy;
use globals;
use backend::BKCommand;
use backend;
......@@ -42,6 +44,7 @@ mod invite;
mod about;
mod start_chat;
mod stickers;
mod leaflet;
pub use self::state::AppState;
use self::message::TmpMsg;
......@@ -49,6 +52,7 @@ pub use self::message::MsgPos;
pub use self::message::LastViewed;
pub use self::room::RoomPanel;
use self::member::SearchType;
pub use self::leaflet::LeafletState;
pub struct AppOp {
pub ui: uibuilder::UI,
......@@ -77,6 +81,8 @@ pub struct AppOp {
pub roomlist: widgets::RoomList,
pub message_box: gtk::ListBox,
pub unsent_messages: HashMap<String, (String, i32)>,
pub header_leaflet: libhandy::Leaflet,
pub chat_state: libhandy::Leaflet,
pub inhibit_escape: bool,
......@@ -105,6 +111,11 @@ impl AppOp {
ui: uibuilder::UI,
tx: Sender<BKCommand>,
itx: Sender<InternalCommand>) -> AppOp {
let header_leaflet = ui.builder.get_object("header_leaflet")
.expect("could not find header_leaflet in .ui file");
let chat_state = ui.builder.get_object("chat_state")
.expect("could not find chat_state in .ui file");
AppOp {
ui: ui,
gtk_app: app,
......@@ -132,6 +143,8 @@ impl AppOp {
since: None,
member_limit: 50,
unsent_messages: HashMap::new(),
header_leaflet,
chat_state,
inhibit_escape: false,
......
......@@ -3,6 +3,7 @@ use gtk::prelude::*;
use appop::AppOp;
use appop::room::RoomPanel;
use appop::LeafletState;
#[derive(Debug, Clone, PartialEq)]
......@@ -89,6 +90,8 @@ impl AppOp {
self.room_panel(RoomPanel::NoRoom);
self.active_room = None;
self.clear_tmp_msgs();
self.set_leaflet_state(LeafletState::Sidebar);
true
},
_ => { false }
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment