need to implement some route behavior, but don't know how - react-native

I'm completelly newbie on react and react-native. So i ask to forgive me for possibly stupid question.
I use redux with react-native-router-flux.
First of all, let me describe the behavior what I want.
I have a scene that shows some info about video. The data is fetching from http page. The video have links to another videos - something like "related videos".
On the related video link clicked I need to open new similar scene but vith info of this new video. This vide have relateds too and so on.
So that's what I trying.
A have one scene with key=film. It renders all the info about video. The info fetchs from remote server. On fething it uses this.props.key to identificate the video page. On related video click I called Action.film({key: NEW_VIDEO_KEY}) and new scene opens, takes new data from fetch and shows new video info. And so on. I do this 5 times for example. So 6 scenes was opened (with the first one). But after pressing the BACK button all previous scenes shows the same info as the last one.
I think, it's because of react-router-flux does not remember scenes data but only the route. Each opened scene was modified props, so after the last scene it hase the last props.
I don't understand how to implement needed behavior as I describe at the beginning.
May be I need to add something like history object to the state and after each opened scene push video object to it and on pop scene pop the last video object from the history object... And return the previous object to the previous scene with Action.pop({video: VIDEO_OBJECT})...
But if I showing the related videos in listview I need to save the scroll position of each scene (( And what about hardware back button...
May be I understand something wrong and there is a more complex and simple way...

Ok. I found a problem. the problem was in my misunderstanding how all things works together. Now it works well as needed.

Related

Component Preloading before opening it

This is a conceptional question, in this case a component is a screen, if that makes sense
Is there a good solution for fluently preloading a component? What I mean by that is perhaps calling a portion of a component, before opening up the view
an example of this is say, snapchat stories, when greyed out on press will simply load. The second press then opens up the view. Essentially allows you to preload before then navigation to the view
Is this a Redux task? Does anyone have an example?
Seems like some concepts are mangled in your mind. What you are trying to achieve is not to preload components, rather run logic before drawing anything on the screen OR preloading some media. Therefore, what you need to do is not to preload anything, but to seperate your logic from your view (let's say video data from showing video itself), retrieve / prepare data (download video for example) and after it is ready show your component.
Also, if what you are trying to preload is just media, you should checkout react-preload.

React native: infinite panResponder pagination

I'll do my best to explain this without code, which, in my opinion will not add clarity to this question as PanResponder code is quite complicated, and i need only concept, not the code itself.
So, i've implemented pagination, something like in this gif.
The idea is to have only 3 "pages" rendered at a time. If user goes to the next scene (swipes from right to left), app fetches one more scene from server and renders it behind currently active scene. etc.
Once user swiped to the next scene, i need to reset panResponder: the "nextScene" should appear at the default position between new nextScene and prevScene and then user will be able to swipe again.
The problem is that i don't know how to make it smooth. Right now i'm just passing new props (new currentScene, nextScene, prevScene) and changing key property of panResponder component. If a new scene contains images, they seems to be refetched each time when i'm changin key. That, probably, fixable by proper caching, but this makes me doubt if my approach is correct. Is there another way to make the reset of panResponder component and put the new scene into default position between new nextScene and prevScene.

keep or remove subviews when loading new – Objective-c

I have an app with different pages, each with subviews like imageviews and button. My question is what's best to do when loading the new page. When a button is tapped on the first page a new UIView appears with different subviews. Should I remove the old page and its subviews or keep them? On the new view I have a button that should lead back to the first page, so if I would remove them when adding the new page I would have to initialize them agin.
What should I do to get it as smooth as possible?
I asked a similar question a few months ago.
Basically, the answer is :
In general, it's better to avoid doing optimizations like this until you've built your app and then profiled it to see how/where it needs improvement..
Code, get it working, and then, learn how to use Instruments, to detect where and when to optimize your app !
Good luck with iOS development.

wait_fences: failed to receive reply: 10004003

i am trying to add splitview into my project code.
I understand that most of the SplitView project have their splitview loaded on the main window.
but i need to have other views before i come to the split view. That's the reason that i added split view to one of my view controller.
i have successfully added my split view.. but currently whenever i change the orientation of my ipad, wait_fences: failed to receive reply: 10004003 will be thrown on the debugging window and will have a lag time during the orientation change.
i have tried to look around for a solution but i failed.
anybody have any idea?
many many thanks!
p/s:i would like to upload my project code.. but i am not sure how to do it.. any tips will be great!
A quick search in Google and clicking the very first link revealed this: http://www.iphonedevsdk.com/forum/iphone-sdk-development-advanced-discussion/17373-wait_fences-failed-receive-reply-10004003-a.html
You can upload your code to a filesharing website and post the link or copy the code into your question and format is accordingly using the "101010" button on top of the text view where you enter the question into.
I had a similar issue. Basically I believe that some UI elements (in my case, an alert box) was delaying some of the other UI elements in the split view to show up. I put my alert box in the didFinishLaunchingWithOptions method (it executes when a flag becomes true) so I no longer get the error (as all the elements are displayed by that point)
Hope the advice is useful for you. good luck.
Edward

Animating Tab Bar page switching

I'm quite confused with the whole animation stuff in iPhone SDK. I tried to study throught the SDK documentation, this website or tried googling it out without success.
I'm unable to get my scenario work.
I have single XIB file, with tab bar and a 4 tabs.
In a special event i want to switch from one page to another "in code", so I call eg: [tabController selectedIndex: 0].
I need this transition to be animated. Is there a way?
If user switches tabs manually, no animated transitions are needed
Also I have one subquestion:
In one of the tabs I have a UITableView with set of items. When user clicks any of these items, another set of items are beign shown (sort of hierarchy browser)
I tried to animate this transition using -deleteRowsAtIndexPaths:withRowAnimation: and -insertRowsAtIndexPaths:withRowAnimation:, but without luck.
Desired transition is shifting the old items set to the left side and the new items from the right side.
This is first time of my iPhone development, when I got lost even with all the forums and documentation. :)
Thanks in advance to anyone trying to help me!
As for your first question: Yes you can.
Try this link for some answer:
transition on tab bar sample code.
In short words: you should add a delegate object to handle the tab bar switching by setting the tabBarController.delegate = self.
Yet, what this forum post won't tell you is that you need to "import" some framework to do it.
First - right-click on the framework folder on the left hand list in Xcode and add an existing framework named: "QuartzCore.framework".
Than - add these lines to your tab bar holder (on .h file):
#import <QuartzCore/CAAnimation.h>
#import <QuartzCore/CAMediaTimingFunction.h>
As for your second question, try to replace the datasource (array or what ever) or create login function on the cell to replace its content.
Enjoy!
First Question: No, you can't animate tab switching. Please read Apple's Human Interface Guidelines on this. Tabs are meant to switch instantly. An animated transition would break the "tab" paradigm.
Second Question: When you tap on a row, the user does not expect other rows to disappear and new ones to appear. Instead, this sounds like a case for a UINavigationController. Please refer to Apple's sample code, specifically the UICatalog for sample code on how to implement this.