Ejemplo n.º 1
0
        void Setup()
        {
            Layer screen = GlobalScreen;

            // create map (see Map.m for map related code)
            var map = new Map (screen);
            map.LoadImage ("map.png");

            // create map cover (masks map behind the list)
            var mapCover = new Layer (screen);
            mapCover.Width = 320f;
            mapCover.Height = screen.Height - 400f;
            mapCover.Y = 400;
            mapCover.Layer.BackgroundColor = CreateColor (220, 220, 220, 255);

            // create list (see List.m for list related code)
            var list = new List (screen);
            list.LoadImage ("list.png");
            list.Y = 300f;

            // create navigation bar
            var navBar = new Layer (screen);
            navBar.LoadImage ("navBar.png");

            // create share sequence (see Share.m)
            var share = new Share (screen);

            // share (plus) button "tap"
            navBar.OnTouchUp = (touches) => {
                UIView.Animate (0.5f, () => {
                    share.Y = 0;
                });
            };
        }
Ejemplo n.º 2
0
		public Map (Layer parent) : base (parent)
		{
			var t = new Timer { Enabled = true, Interval = 10 };
			t.Elapsed += (sender, e) => Tick ();
			isInertiaing = false;
			velocity = CGPoint.Empty;
			lastTime = 0;
		}
Ejemplo n.º 3
0
		public List (Layer parent) : base (parent)
		{
			var t = new Timer { Enabled = true, Interval = 10 };
			t.Elapsed += (sender, e) => Tick ();
			isInertiaing = false;
			velocity = 0;
			lastTime = 0;

			spring = new Spring {
				Strength = 0.25,
				Damping = 0.4
			};

			isSpringing = false;
		}
Ejemplo n.º 4
0
		public KeyboardTyping (Layer parent) : base (parent)
		{
			Width = Screen.GlobalScreen.Width;
			Height = Screen.GlobalScreen.Height;

			for (int i = 1; i <= 18; i++) {
				var frame = new Layer (this);

				string imageName = i < 10 ? string.Format ("typing.00{0}.png", i) : string.Format ("typing.0{0}.png", i);
				frame.LoadImage (imageName);

				frame.OnTouchDown = (touches) => {
					NextFrame ();
				};

				frame.Hidden = i != 1;
			}

			KeyboardTypingFrame = 1;
		}
Ejemplo n.º 5
0
        public Camera(Layer parent)
            : base(parent)
        {
            CALayer preview = CameraLayer;
            if (preview != null) {
                Layer.AddSublayer (preview);
                preview.Position = new CGPoint (160, 309);
                preview.Bounds = new CGRect (preview.Bounds.Location.X, preview.Bounds.Location.Y, 320, 320f * 16 / 9);
                preview.Transform = CATransform3D.MakeRotation ((nfloat)Math.PI, 0f, 1f, 0f);

                var previewMask = new CALayer ();
                Layer.AddSublayer (previewMask);

                previewMask.Position = new CGPoint (160, 260);
                previewMask.Bounds = new CGRect (previewMask.Bounds.Location.X, previewMask.Bounds.Location.Y, 320f, 320f);
                previewMask.BackgroundColor = CreateColor (0, 0, 0, 255);
                preview.Mask = previewMask;
            } else {
                Layer fakePreview = new Layer (this);
                fakePreview.LoadImage ("toast.jpg");
                fakePreview.Width = fakePreview.Height = 320;
                fakePreview.Y = Screen.GlobalScreen.Height * 0.5f - fakePreview.Height * 0.5f;
            }
        }
Ejemplo n.º 6
0
		public Share (Layer parent) : base (parent)
		{
			Layer screen = Screen.GlobalScreen;

			// position at bottom edge of screen
			Y = screen.Height;
			LoadImage ("camera.png");
			new Camera (this);

			var stencil = new Layer (this);
			stencil.Width = stencil.Height = 300;
			stencil.Layer.CornerRadius = stencil.Width / 2;
			stencil.Layer.BorderColor = CreateColor (255, 255, 255, 255);
			stencil.Layer.BorderWidth = 4;
			stencil.Layer.ShadowColor = CreateColor (0, 0, 0, 255);
			stencil.Layer.ShadowOpacity = 1;
			stencil.Layer.ShadowRadius = 1;
			stencil.Layer.ShadowOffset = CGSize.Empty;
			stencil.X = Width / 2 - stencil.Width / 2;
			stencil.Y = Height / 2 - stencil.Height / 2;

			var cover = new Layer (this);
			cover.Width = cover.Height = 330;
			cover.Layer.BackgroundColor = CreateColor (0, 0, 0, 255);
			cover.X = Width / 2 - cover.Width / 2;
			cover.Y = Height / 2 - cover.Height / 2;
			cover.Hidden = true;

			var toast = new Layer (this);
			toast.LoadImage ("toast.jpg");
			toast.Width = toast.Height = screen.Width;
			toast.Y = screen.Height / 2 - toast.Height / 2;
			toast.Layer.Opacity = 0;

			var keyboard = new Layer (screen);
			keyboard.LoadImage ("keyboard.png");
			keyboard.Y = screen.Height;

			var keyboardTyping = new KeyboardTyping (screen);
			keyboardTyping.Hidden = true;

			var postNavBar = new Layer (screen);
			postNavBar.LoadImage ("postNavBar.png");
			postNavBar.Y = -postNavBar.Height;

			OnTouchUp = (touches) => {
				// get position of touch
				UITouch touch = (UITouch)touches.AnyObject;
				CGPoint touchPos = touch.LocationInView (screen);

				if (touchPos.X < 100 && touchPos.Y > screen.Height - 100) {
					UIView.Animate (0.5, () => {
						Y = screen.Height;
					});
				} else if (touchPos.X > 100 && touchPos.Y > screen.Height - 100) {
					UIView.PerformWithoutAnimation (() => {
						cover.Hidden = false;
					});

					UIView.Animate (0.5, () => {
						toast.Layer.Opacity = 1;
					}, () => {
						UIView.Animate (0.5, () => {
							toast.Y = 48;
							postNavBar.Y = 0;
							keyboard.Y = screen.Height - keyboard.Height;
						}, () => {
							var firstKeyboardTypingFrame = (Layer)keyboardTyping.Subviews [0];

							UIView.PerformWithoutAnimation (() => {
								keyboardTyping.Hidden = false;
								firstKeyboardTypingFrame.Layer.Opacity = 0;
							});

							UIView.Animate (0.5, () => {
								firstKeyboardTypingFrame.Layer.Opacity = 1;
							});
						});
					});
				}
			};

			postNavBar.OnTouchUp = (touches) => {
				keyboardTyping.Hidden = true;
				UIView.Animate (0.5, () => {
					Y = screen.Height;
					toast.Y = screen.Height / 2f - toast.Height / 2f;
					toast.Layer.Opacity = 0;
					postNavBar.Y = -postNavBar.Height;
					keyboard.Y = screen.Height;
				}, () => {
					cover.Hidden = true;
				});
			};
		}