2 * Copyright (c) 2016 Samsung Electronics Co., Ltd All Rights Reserved
4 * Licensed under the Apache License, Version 2.0 (the License);
5 * you may not use this file except in compliance with the License.
6 * You may obtain a copy of the License at
8 * http://www.apache.org/licenses/LICENSE-2.0
10 * Unless required by applicable law or agreed to in writing, software
11 * distributed under the License is distributed on an AS IS BASIS,
12 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 * See the License for the specific language governing permissions and
14 * limitations under the License.
18 using System.Collections.Generic;
22 public class NaviframeEventArgs : EventArgs
24 public EvasObject Content { get; set; }
26 public class Naviframe : Widget
28 Interop.SmartEvent _transitionFinished;
29 readonly List<NaviItem> _itemStack = new List<NaviItem>();
30 public Naviframe(EvasObject parent) : base(parent)
32 _transitionFinished = new Interop.SmartEvent(this, Handle, "transition,finished");
33 _transitionFinished.On += (s, e) => AnimationFinished?.Invoke(this, EventArgs.Empty);
40 /// It is always called when NaviItem was removed.
41 /// (even if removed by NaviItem.Delete())
42 /// This event will be invoked in progress of Pop/Delete operation.
43 /// After called Popped event, Pop/Delete method will be returned
45 public event EventHandler<NaviframeEventArgs> Popped;
46 public event EventHandler AnimationFinished;
47 public IReadOnlyList<NaviItem> NavigationStack
49 get { return _itemStack; }
52 public bool PreserveContentOnPop
56 return Interop.Elementary.elm_naviframe_content_preserve_on_pop_get(Handle);
60 Interop.Elementary.elm_naviframe_content_preserve_on_pop_set(Handle, value);
64 public bool DefaultBackButtonEnabled
68 return Interop.Elementary.elm_naviframe_prev_btn_auto_pushed_get(Handle);
72 Interop.Elementary.elm_naviframe_prev_btn_auto_pushed_set(Handle, value);
76 public NaviItem Push(EvasObject content)
78 return Push(content, null);
80 public NaviItem Push(EvasObject content, string title)
82 IntPtr item = Interop.Elementary.elm_naviframe_item_push(Handle, title, IntPtr.Zero, IntPtr.Zero, content.Handle, null);
83 NaviItem naviItem = NaviItem.FromNativeHandle(item, content);
84 _itemStack.Add(naviItem);
85 naviItem.Popped += ItemPoppedHandler;
89 public NaviItem InsertBefore(NaviItem before, EvasObject content)
91 return InsertBefore(before, content, "");
93 public NaviItem InsertBefore(NaviItem before, EvasObject content, string title)
95 IntPtr item = Interop.Elementary.elm_naviframe_item_insert_before(Handle, before, title, IntPtr.Zero, IntPtr.Zero, content, null);
96 NaviItem naviItem = NaviItem.FromNativeHandle(item, content);
97 int idx = _itemStack.IndexOf(before);
98 _itemStack.Insert(idx, naviItem);
99 naviItem.Popped += ItemPoppedHandler;
103 public NaviItem InsertAfter(NaviItem after, EvasObject content)
105 return InsertAfter(after, content, "");
107 public NaviItem InsertAfter(NaviItem after, EvasObject content, string title)
109 IntPtr item = Interop.Elementary.elm_naviframe_item_insert_after(Handle, after, title, IntPtr.Zero, IntPtr.Zero, content, null);
110 NaviItem naviItem = NaviItem.FromNativeHandle(item, content);
111 int idx = _itemStack.IndexOf(after);
112 _itemStack.Insert(idx + 1, naviItem);
113 naviItem.Popped += ItemPoppedHandler;
119 Interop.Elementary.elm_naviframe_item_pop(Handle);
122 protected override IntPtr CreateHandle(EvasObject parent)
124 return Interop.Elementary.elm_naviframe_add(parent.Handle);
127 void ItemPoppedHandler(object sender, EventArgs e)
129 NaviItem item = sender as NaviItem;
132 _itemStack.Remove(item);
133 Popped?.Invoke(this, new NaviframeEventArgs() { Content = item.Content });