<?xml version="1.0" encoding="UTF-8"?><rss xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:atom="http://www.w3.org/2005/Atom" version="2.0" xmlns:cc="http://cyber.law.harvard.edu/rss/creativeCommonsRssModule.html">
    <channel>
        <title><![CDATA[Stories by Evgeny Matviyenko on Medium]]></title>
        <description><![CDATA[Stories by Evgeny Matviyenko on Medium]]></description>
        <link>https://medium.com/@evgeny.matviyenko?source=rss-f2d57704a373------2</link>
        <image>
            <url>https://cdn-images-1.medium.com/fit/c/150/150/1*Gqms-Bxq-7AaUKl4oTXcxQ.jpeg</url>
            <title>Stories by Evgeny Matviyenko on Medium</title>
            <link>https://medium.com/@evgeny.matviyenko?source=rss-f2d57704a373------2</link>
        </image>
        <generator>Medium</generator>
        <lastBuildDate>Thu, 19 Nov 2026 08:36:37 GMT</lastBuildDate>
        <atom:link href="https://medium.com/@evgeny.matviyenko/feed" rel="self" type="application/rss+xml"/>
        <webMaster><![CDATA[yourfriends@medium.com]]></webMaster>
        <atom:link href="http://medium.superfeedr.com/" rel="hub"/>
        <item>
            <title><![CDATA[Chatting with Firebase]]></title>
            <link>https://medium.com/uptech-team/chatting-with-firebase-4333bdeec339?source=rss-f2d57704a373------2</link>
            <guid isPermaLink="false">https://medium.com/p/4333bdeec339</guid>
            <category><![CDATA[mobile]]></category>
            <category><![CDATA[ios]]></category>
            <category><![CDATA[apps]]></category>
            <category><![CDATA[chat]]></category>
            <category><![CDATA[firebase]]></category>
            <dc:creator><![CDATA[Evgeny Matviyenko]]></dc:creator>
            <pubDate>Mon, 04 Feb 2019 11:25:53 GMT</pubDate>
            <atom:updated>2019-02-05T12:23:05.128Z</atom:updated>
            <content:encoded><![CDATA[<figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*ZC-593A2FnNlBCp-JNXPeA.png" /></figure><p>Perhaps everyone will agree that chatting became an indivisible part of modern life. It makes it so easy to communicate with your relatives, friends, coworkers, partners any time, almost anywhere.</p><p><a href="https://adage.com/article/digitalnext/message-marketers-mobile-chat-killer-app/297951/">Chat is the killer app of the smartphones.</a></p><p>Besides general-purpose chats like Telegram, Viber, WhatsApp and Messenger, a lot of businesses implement their own solutions for specific purposes, like contacting your cab driver, courier or landlord.</p><p>From developer’s point of view implementing chat may become a pain, for the first time — for sure. The reason of this is a synchronization between server and client, which is done with properly mixed powers of local database, http requests and socket connection. This is where Firestore can help us as it solves a problem of synchronization almost completely.</p><p>Google’s <a href="https://cloud.google.com/firestore/">Cloud Firestore</a> is a NoSQL document database that allows users to create serverless applications.</p><p>In this article series we will examine how to implement a chat app for iOS using Firestore. Entire process will be split into 3 parts:</p><ol><li>Requirements and model;</li><li>Firebase interactions;</li><li>UI.</li></ol><p>Information is targeted for beginners in mobile app programming. Only the last article will be strictly bound to iOS SDK, so you can apply the lessons to Android, React Native and Web as well.</p><p>In this article we will review requirements and implement models following plan below:</p><ul><li>Requirements</li><li>Defining Domain Model</li><li>Deserialization</li><li>Serialization</li></ul><h4>Let’s Start The Party</h4><p>Any complex feature can be implemented easily with proper model design. In this article we will learn how to define and implement model both abstract and specific for programming language (Swift in our case).</p><p>At first let’s define functionality scope to see what we should cover.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*8ULWPUh9GMnIWYF6PO7Dkw.png" /></figure><h4><strong>Requirements</strong></h4><p>The app will consist of following screens:</p><ul><li><em>Authentication.</em> User can enter his email and password. App creates an account for new user or lets old user sign in. New users must also specify their name;</li><li><em>List of available chats.</em> Contains list of chats that current user is member of. Each chat has a name and last sent message. User can view particular chat, create a new one or sign out. When there are no chats available user sees a message suggesting to start using the app;</li><li><em>Chat.</em> Shows a list of users’ and system messages. Messages are being grouped by day of sending and common sender. Each message has time when it was sent and read status. Screen also shows a sheet with following options: invite user to chat, rename chat and leave chat.</li></ul><p>For authentication we will use <a href="https://firebase.google.com/docs/auth/">FirebaseAuth</a>. It has nice ready-to-use UI and support for third-party social networks auth. In our case, we will only use email and password sign in to keep things simple, but you can add social login easily.</p><h4>Defining Domain Model</h4><p>Keeping in mind app functionality, let’s define three main entities:</p><ul><li>Chat Represents a chat that has a name and creation date. Has one to many relationship to events and to users;</li><li>Event The thing we show in list on Chat screen. Can be a message from user or system info. If Event is a message, it has a text body, sender and read status. If Event is a system info, it can be one of this types: createdChat, addedUser, userLeft, renamedChat;</li><li>User Name and email of user. These will be taken from FirebaseAuth and posted to Firestore.</li></ul><p>These are high-level entities, each entity will be represented with one or more Swift structs for different layers of abstraction.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*u4QWPB-mRFoCOzMlwuXPFg.png" /></figure><h4>User Entity</h4><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/6fecc49ba7c40223e03ff87f1dd4b044/href">https://medium.com/media/6fecc49ba7c40223e03ff87f1dd4b044/href</a></iframe><p>User entity is simple, there is no need to create multiple structs for it.</p><h4>Chat Entity</h4><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/a7fe4878cc8d40b63a9252f473452a39/href">https://medium.com/media/a7fe4878cc8d40b63a9252f473452a39/href</a></iframe><p>Same as User, Chat entity has only one struct to deal with in whole app. The only thing that differs is that we cannot store Date type as it is in Firestore, so it will be converted to timestamp. Also this struct stores latest message, which we will cover in next section.</p><h4>Event Entity</h4><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/41b9971c0eff1a4bea98213424a57492/href">https://medium.com/media/41b9971c0eff1a4bea98213424a57492/href</a></iframe><p>Event is a bit more complex. It has nested enums with associated values that cannot be serialized into JSON (Firestore is JSON database). This is why Event requires different, flat representation for storing/transportation.</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/5d41a38c85a638e1ce583915b5c0d95a/href">https://medium.com/media/5d41a38c85a638e1ce583915b5c0d95a/href</a></iframe><p>Now we have a flat FirebaseEvent model that can be converted into JSON, but can be in invalid state that doesn’t make sense. To understand what invalid state means let’s take a look at initialization of Api models.</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/cb96ea8ce9ce443b2d3564d87b9bbcb0/href">https://medium.com/media/cb96ea8ce9ce443b2d3564d87b9bbcb0/href</a></iframe><p>Here every initialization fail represents invalid state of model. For example FirebaseEvent can have type message but contain info instead. We don’t want to deal with this validations later. That is why we separate complex entities to different structs. In view controllers we will only operate with high-level representation.</p><h4>Finalize Models</h4><p>To keep things consistent we rename models that have only one struct and create aliases for high-level versions of them. So ApiUser becomes FirebaseUser, ApiChat becomes FirebaseChat and ApiMessage becomes FirebaseMessage. ApiUser, ApiChat, ApiMessage are now type aliases for corresponding Firebase models.</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/3db268ddecef845d1e2e9ddf6d1b978d/href">https://medium.com/media/3db268ddecef845d1e2e9ddf6d1b978d/href</a></iframe><p>To sum up, structs with Firebase prefix will be used only for transportation and will be abstracted from domain logic code.</p><h4>Deserialization</h4><p>Firestore models are being represented by DocumentSnapshot class in it’s API. We need a way to convert it to structs we implemented recently. For this purpose I created a protocol FirebaseDecodable and methods for initializing models, that conform it, from Firestore snapshots.</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/a8d3318e38a0eb82aac4c754f8631c3c/href">https://medium.com/media/a8d3318e38a0eb82aac4c754f8631c3c/href</a></iframe><p>Now let’s conform our Firebase models to FirebaseDecodable protocol. I will show an example of one model, all others can be done by analogue.</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/2502f3bcc9976b5e194f7245ea60a1eb/href">https://medium.com/media/2502f3bcc9976b5e194f7245ea60a1eb/href</a></iframe><p>Here we convert iOS Foundation Date object to Firestore’s Timestamp to save model as dictionary to Firestore later.</p><p>Now we are ready to deserialize database objects into Swift structs. Next step is implementing serialization.</p><h4>Serialization</h4><p>We could create similar protocol FirebaseEncodable as opposite to FirebaseDecodable, but saving info to Firestore isn’t same straightforward as fetching.</p><p>At first, we assumed that our structs can only represent entities that are already in database, because each of it contains an identifier. Beside that, we want to use server-side values for some properties like createdAt timestamps, because taking timestamp value from user’s phone is error prone. For example, user 1 with valid time 7:00 PM sends a message to chat. User 2 with wrong time 6:00 PM sends a message after user 1. If database query depends on createdAt property, message from user 2 will appear above message from user 1, which is incorrect. Firestore provides some API to handle such cases, we will take a look at it in details in next part.</p><p>Let’s create auxiliary high-level structs for saving info to database later.</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/610cb79149711ca773842de5ec557bf4/href">https://medium.com/media/610cb79149711ca773842de5ec557bf4/href</a></iframe><p>We will call service object method passing this model to create event in the database.</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/bc649b33f64010e52ad89d9593287ab0/href">https://medium.com/media/bc649b33f64010e52ad89d9593287ab0/href</a></iframe><p>Similar to events, this will be used for creating new chats.</p><h4>Conclusion</h4><p>We have implemented all models that we need for describing domain logic. You can find project code <a href="https://github.com/EvgenyMatviyenko/ChatModels/tree/master/Chat/Models">here</a>.</p><p>In next part we will implement service object class, that will encapsulate Firestore interactions to abstract them from other parts of the app.</p><p>Clap 👏 👏 👏 if it was helpful. Follow <a href="https://blog.uptech.team/">UPTech blog</a> to find out more useful articles about mobile app development.</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=4333bdeec339" width="1" height="1" alt=""><hr><p><a href="https://medium.com/uptech-team/chatting-with-firebase-4333bdeec339">Chatting with Firebase</a> was originally published in <a href="https://medium.com/uptech-team">Uptech Software Development Company</a> on Medium, where people are continuing the conversation by highlighting and responding to this story.</p>]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[How to implement expandable menu on iOS (like in Airbnb)]]></title>
            <link>https://medium.com/uptech-team/how-to-implement-expandable-menu-on-ios-like-in-airbnb-3d2bdd97b049?source=rss-f2d57704a373------2</link>
            <guid isPermaLink="false">https://medium.com/p/3d2bdd97b049</guid>
            <category><![CDATA[ios-app-development]]></category>
            <category><![CDATA[development]]></category>
            <category><![CDATA[mobile-app-development]]></category>
            <category><![CDATA[tech]]></category>
            <category><![CDATA[ios]]></category>
            <dc:creator><![CDATA[Evgeny Matviyenko]]></dc:creator>
            <pubDate>Tue, 18 Jul 2017 10:09:56 GMT</pubDate>
            <atom:updated>2018-02-20T12:31:06.271Z</atom:updated>
            <content:encoded><![CDATA[<figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*4mjos0c1rx7qIAdfjJy6Wg.png" /></figure><p>A few months ago I had a chance to implement an expandable menu that behaves same as the one in a popular iOS application (like Airbnb). Then I thought it would be great to have it available in form of a library. Now I want to share with you some solutions that I have created in order to implement beautiful scroll driven animations.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/290/1*c4e83KM3BMh8p04jXY3m1A.gif" /></figure><p>The library supports 3 states. The main goal is to achieve smooth transitions between states while scrolling <a href="https://developer.apple.com/documentation/uikit/uiscrollview">UIScrollView</a>.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*yghDAza2CgWGTfXYIRJ9kQ.png" /><figcaption>Supported states</figcaption></figure><h3>UIScrollView</h3><p><a href="https://developer.apple.com/documentation/uikit/uiscrollview">UIScrollView</a> is an iOS SDK view that supports scrolling and zooming. It is used as a superclass of <a href="https://developer.apple.com/documentation/uikit/uitableview">UITableView</a> and <a href="http://uicollectionview/">UICollectionView</a>, so you can use them wherever UIScrollView is supported.</p><p>UIScrollView uses <a href="https://developer.apple.com/documentation/uikit/uipangesturerecognizer">UIPanGestureRecognizer</a> internally to detect scrolling gestures. Scrolling state of UIScrollView is defined as contentOffset: CGPoint property. Scrollable area is union of contentInsets and contentSize. So the starting contentOffset is <em>CGPoint(x: -contentInsets.left, y: -contentInsets.right)</em> and ending is <em>CGPoint(x: contentSize.width — frame.width+contentInsets.right, y: contentSize.height — frame.height+contentInsets.bottom).</em></p><p>UIScrollView has a bounces: Bool property. In case bounces is on contentOffset can change to value above/below limits. We need to keep that in mind.</p><iframe src="https://cdn.embedly.com/widgets/media.html?src=https%3A%2F%2Fwww.youtube.com%2Fembed%2FfgwVqCGgHZA%3Ffeature%3Doembed&amp;url=http%3A%2F%2Fwww.youtube.com%2Fwatch%3Fv%3DfgwVqCGgHZA&amp;image=https%3A%2F%2Fi.ytimg.com%2Fvi%2FfgwVqCGgHZA%2Fhqdefault.jpg&amp;key=a19fcc184b9711e1b4764040d3dc5c07&amp;type=text%2Fhtml&amp;schema=youtube" width="854" height="480" frameborder="0" scrolling="no"><a href="https://medium.com/media/eeb07e73dceb50d52b4990b54856c095/href">https://medium.com/media/eeb07e73dceb50d52b4990b54856c095/href</a></iframe><p>We are interested in contentOffset: CGPoint property for changing our menu state. The main way of observing scroll view contentOffset is setting an object to delegate property and implementing scrollViewDidScroll(UIScrollView) method. There is no way to use delegate without affecting other client code in Swift (because NSProxy is not available) so I have decided to use Key-Value Observing.</p><h3>Observable</h3><p>I have createdObservable class that can wrap any type of observing.</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/5afbb44521380f90854a90dfa0584055/href">https://medium.com/media/5afbb44521380f90854a90dfa0584055/href</a></iframe><p>And two Observable subclasses:</p><ul><li>KVObservable — for wrapping Key-Value Observing.</li></ul><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/7fbfcccde2598348b5a8bd790833223f/href">https://medium.com/media/7fbfcccde2598348b5a8bd790833223f/href</a></iframe><ul><li>GestureStateObservable — for wrapping target-action observing of UIGestureRecognizer state.</li></ul><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/3999f12ace88e51daf733ae7e8576fca/href">https://medium.com/media/3999f12ace88e51daf733ae7e8576fca/href</a></iframe><h3>Scrollable</h3><p>To make library testable I have implemented Scrollable protocol. I also needed a way to make UIScrollView provide Observables for contentOffset, contentSize and panGestureRecognizer.state. Protocol conformance is a good way to do this. Apart from observables it contains all properties that library needs to use. It also contains updateContentOffset(CGPoint, animated: Bool) method to set contentOffset with animation.</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/25abf81bf88f7bbab15e5fb9b57fb1dd/href">https://medium.com/media/25abf81bf88f7bbab15e5fb9b57fb1dd/href</a></iframe><p>I have not used a native setContentOffset(...) method of UIScrollView for updating contentOffset cause UIKit animations API is more flexible IMO. The problem here is that setting contentOffset directly to property doesn’t stop UIScrollView deceleration, so updateContentOffset(…) method stops it via setting current contentOffset without animation.</p><h3>State</h3><p>I wanted to have predictable menu state. That is why I have isolated all mutable state in State struct that contains offset, isExpandedStateAvailable and configuration properties.</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/82c34ece57f6222c032eed6373351eee/href">https://medium.com/media/82c34ece57f6222c032eed6373351eee/href</a></iframe><p>offset is just an inverted height of menu. I decided to use offset instead of height, because scrolling down decreases height when scrolling up increases. offset is being calculated like <em>offset = previousOffset + (contentOffset.y — previousContentOffset.y)</em>;</p><ul><li>isExpandedStateAvailable property determines should offset go below -normalStateHeight to -expandedStateHeight or not;</li><li>configuration is a struct that contains menu height constants.</li></ul><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/98d10b23592ac31c4cf27ad78646a03f/href">https://medium.com/media/98d10b23592ac31c4cf27ad78646a03f/href</a></iframe><h3>BarController</h3><p>BarController is the main object that makes all state calculation magic and provides state changes to users.</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/3ead9d9f14a9c461a4341213d98d3e71/href">https://medium.com/media/3ead9d9f14a9c461a4341213d98d3e71/href</a></iframe><p>It takes stateReducer, configuration and stateObserver as initializer arguments.</p><ul><li>stateObserver closure is called on a didSet observer of state property. It notifies library user about state changes.</li><li>stateReducer is a function that takes previous state, some scrolling context params and returns a new state. Injecting it through initializer provides decoupling between state calculation logic and BarController object itself.</li></ul><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/78b46b7354be6e1a5badba13ff911d94/href">https://medium.com/media/78b46b7354be6e1a5badba13ff911d94/href</a></iframe><p>Default state reducer calculates difference between contentOffset.y and previousContentOffset.y and applies provided transformers one-by-one. After that it returns new state with offset = previousState.offset + deltaY.</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/1d4da5899e713988af973834c0320372/href">https://medium.com/media/1d4da5899e713988af973834c0320372/href</a></iframe><p>The library uses 3 transformers for reducing state:</p><ul><li>ignoreTopDeltaYTransformer — makes sure that scrolling above top of UIScrollView is being ignored and does not affect BarController state;</li></ul><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/a7cd1cd815d7b1bd7b309dbbbd2923ab/href">https://medium.com/media/a7cd1cd815d7b1bd7b309dbbbd2923ab/href</a></iframe><ul><li>ignoreBottomDeltaYTransformer — same as ignoreTopDeltaYTransformer, but for scrolling below bottom;</li></ul><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/11cc516a7eef47bb47cc201b4da6dd3a/href">https://medium.com/media/11cc516a7eef47bb47cc201b4da6dd3a/href</a></iframe><ul><li>cutOutStateRangeDeltaYTransformer — cuts out extra delta Y, that goes out of minimum/maximum limits of BarController supported states.</li></ul><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/023e7362b725a6a98e1d48725399adcc/href">https://medium.com/media/023e7362b725a6a98e1d48725399adcc/href</a></iframe><p>BarController calls a stateReducer and sets result as a state every time contentOffset changes.</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/fbf4571ca51a2929317d6dc31a7f87df/href">https://medium.com/media/fbf4571ca51a2929317d6dc31a7f87df/href</a></iframe><p>For now the library is able to transform contentOffset changes into internal state changes, but isExpandedStateAvailable state property is never being mutated as well as state transitions are not being finished.</p><p>That is where panGestureRecognizer.state observing comes in:</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/6ba5e9208a3fa4ec1ba85ca97682ea7b/href">https://medium.com/media/6ba5e9208a3fa4ec1ba85ca97682ea7b/href</a></iframe><ul><li>Pan gesture sets isExpandedStateAvailable state property to true in case panning began in the top of scrolling or in case we already have an expanded state;</li></ul><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/8ae1a23abcc894283872ac99903b7eb2/href">https://medium.com/media/8ae1a23abcc894283872ac99903b7eb2/href</a></iframe><ul><li>Pan gesture change sets isExpandedStateAvailable if state offset reached normal state;</li></ul><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/11f12306eb266621ede4fb3f4735eaf8/href">https://medium.com/media/11f12306eb266621ede4fb3f4735eaf8/href</a></iframe><ul><li>Pan gesture end finds offset that is most near current state, adds a difference to current content offset and calls updateContentOffset(CGPoint, animated: Bool) with result content offset to end state transition animation.</li></ul><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/62520aa7621685a33511a822a44a934d/href">https://medium.com/media/62520aa7621685a33511a822a44a934d/href</a></iframe><p>So expanded state becomes available only when the user starts scrolling at the top of available scrollable area. If expanded state was available and user scrolls below normal state, expanded state turns off. And if the user ends the panning gesture during state transition BarController updates content offset with animation to finish it.</p><h3>Binding UIScrollView to BarController</h3><p>BarController contains 2 public methods that the user can use to assign UIScrollView. In most cases the user should use set(scrollView: UIScrollView) method. There is also preconfigure(scrollView: UIScrollView) method, it configures the scroll view’s visual state to be consistent with the current BarController state. It should be used when the scroll view is about to be swapped. For example the user can replace current scroll view with animation and want second scroll view to be visually configured in the beginning of animation. After animation completion the user should call set(scrollView: UIScrollView). preconfigure(scrollView: UIScrollView) method is not needed to be called if UIScrollView is set once, cause set(scrollView: UIScrollView) calls it internally.</p><p>preconfigure method finds difference between contentSize height and frame height and puts it as a bottom content inset so that the menu remains expandable, configures contentInsets.top and scrollIndicatorInsets.top and sets initial contentOffset to make the new scroll view visually consistent with the state offset.</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/4f018f69338fdf39da01c2a2446c0b0c/href">https://medium.com/media/4f018f69338fdf39da01c2a2446c0b0c/href</a></iframe><h3>API</h3><p>To inform users about state changes BarController calls injected stateObserver function with changed State model object.</p><p>State struct has several public methods for getting useful information from internal state:</p><ul><li>height()— returns reversed offset, actually height of menu;</li></ul><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/bff6b70ebd5a6cdc66a8aeb73a4f344f/href">https://medium.com/media/bff6b70ebd5a6cdc66a8aeb73a4f344f/href</a></iframe><ul><li>transitionProgress()— returns transition progress from 0 to 2, where <em>0 — compact state, 1 — normal state, 2 — expanded state</em>;</li></ul><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/5bf85cf6177b9752f36d67b8c1bbc50b/href">https://medium.com/media/5bf85cf6177b9752f36d67b8c1bbc50b/href</a></iframe><ul><li>value(compactNormalRange: ValueRangeType, normalExpandedRange: ValueRangeType) — returns transition progress mapped to one of 2 range types according to the current StateRange.</li></ul><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/9f71571d0ded056a618644491231adfd/href">https://medium.com/media/9f71571d0ded056a618644491231adfd/href</a></iframe><p>Here is an example from AirBarExampleApp with a use of State public methods. airBar.frame.height is animated with height() and backgroundView.alpha is animated using value(...). Background view alpha here is interpolated from transition progress to (0, 1) range in compact-normal transition and constantly 1 in normal-expanded transition.</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/fa2224a3c5362c7491ce1645fd2729f0/href">https://medium.com/media/fa2224a3c5362c7491ce1645fd2729f0/href</a></iframe><h3>Conclusions</h3><p>As a result, I got a beautiful scroll driven menu with predictable state and a lot of experience working with UIScrollView.</p><p>The library, example application and installation guide can be found here:</p><p><a href="https://github.com/uptechteam/AirBar">uptechteam/AirBar</a></p><p>Feel free to use it for your own purposes. Let me know if you have any difficulties with it.</p><p>And what is your experience working with UIScrollView? And with scroll driven animations? Feel free to share / ask questions in the comments, I would be glad to help.</p><p>Thank you for reading!</p><p>We did the investigation of the topic for the <a href="https://www.freebirdrides.com/">Freebird Rides</a> app we’ve built here at <a href="https://uptech.team/">UPTech</a>.</p><p><em>If you find this helpful, click the</em> 👏 <em>below so other can enjoy it too. Follow us for more articles on how to build great products.</em></p><iframe src="https://cdn.embedly.com/widgets/media.html?src=https%3A%2F%2Fupscri.be%2F0de99e%3Fas_embed%3Dtrue&amp;dntp=1&amp;url=https%3A%2F%2Fupscri.be%2F0de99e%2F&amp;image=https%3A%2F%2Fe.enpose.co%2F%3Fkey%3DdRXnS9Gplk%26w%3D700%26h%3D425%26url%3Dhttps%253A%252F%252Fupscri.be%252F0de99e%252F%253Fenpose&amp;key=d04bfffea46d4aeda930ec88cc64b87c&amp;type=text%2Fhtml&amp;schema=upscri" width="800" height="400" frameborder="0" scrolling="no"><a href="https://medium.com/media/dc55d58edab9ea72daa656cc10f6fde8/href">https://medium.com/media/dc55d58edab9ea72daa656cc10f6fde8/href</a></iframe><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=3d2bdd97b049" width="1" height="1" alt=""><hr><p><a href="https://medium.com/uptech-team/how-to-implement-expandable-menu-on-ios-like-in-airbnb-3d2bdd97b049">How to implement expandable menu on iOS (like in Airbnb)</a> was originally published in <a href="https://medium.com/uptech-team">Uptech Software Development Company</a> on Medium, where people are continuing the conversation by highlighting and responding to this story.</p>]]></content:encoded>
        </item>
    </channel>
</rss>