1
TDDC73 Lecture 3 1 Agenda Questions Complex components - - PowerPoint PPT Presentation
TDDC73 Lecture 3 1 Agenda Questions Complex components - - PowerPoint PPT Presentation
TDDC73 Lecture 3 1 Agenda Questions Complex components Network REST and/or GraphQL Screen navigation 2 Organisation of code Biggest challenge of UI development (Ok one of ) Maintaining the
Agenda
- Questions
- Complex components
- Network
- REST and/or GraphQL
- Screen navigation
2
Organisation of code
- Biggest challenge of UI development (Ok one of )
- Maintaining the correct and same state between the UI and
the system/model/backend
- Separation of concerns
- Architecture Presentation Patterns
- MVC
- MVP
- MVVM
3
Model-View-Presenter MVP
4
Demo
- Android Adapter
5
Network
- REST
6
DEMO old school
7
Network
- GraphQL
- Putting REST to rest
8
GraphQL
- A query language for back-ends
- Front-end driven
- You decide what you want
- Subway vs Pressbyrån
- Singel endpoint
- Typed
9
Navigation
10
Flutter
- Routes
- Pages/Screens
- Navigation
- To move between Routes
- Push and Pop
- Hero
- Animation between Routes
11
Routes
12
class FirstRoute extends StatelessWidget { @override Widget build(BuildContext context) { return Scaffold( appBar: AppBar( title: Text('First Route'), ), body: Center( child: RaisedButton( child: Text('Open route'), }, ), ), ); } } class SecondRoute extends StatelessWidget { @override Widget build(BuildContext context) { return Scaffold( appBar: AppBar( title: Text("Second Route"), ), body: Center( child: RaisedButton(¨ child: Text('Go back!'), ), ), ); } }
Navigation
13
child: RaisedButton(
- nPressed: () {
Navigator.pop(context); }, child: Text('Go back!'), ), child: RaisedButton( child: Text('Open route'),
- nPressed: () {
Navigator.push( context, MaterialPageRoute(builder: (context) => SecondRoute()), ); }, ), routes: { '/': (context) => FirstScreen(), '/info': (context) => SecondRoute(), }, Navigator.pushNamed(context, ‘/info');
Hero
14
Hero( tag: 'imageHero', child: Image.network( 'https://picsum.photos/250?image=9', ), );
React-Native
- Screens
- Routes describes Screens
- Offers a few options
- StackNaviagator (Similar to Flutter)
const MainNavigator = createStackNavigator({ Home: {screen: HomeScreen}, Profile: {screen: ProfileScreen}, });
15
Screen (Just a component)
16
class HomeScreen extends React.Component { static navigationOptions = { title: 'Welcome', }; render() { const {navigate} = this.props.navigation; return ( <Button title="Go to Anders's profile"
- nPress={() => navigate('Profile', {name: ‘Anders'})}
/> ); } createStackNavigator( { Home: HomeScreen, Profile: DetailsScreen, }, { initialRouteName: 'Home', } );
Push,navigate,Back
17
<Button title="Go to Details... again"
- nPress={() => this.props.navigation.push('Details')}
/> <Button title="Go to Home"
- nPress={() => this.props.navigation.navigate('Home')}
/> <Button title="Go back"
- nPress={() => this.props.navigation.goBack()}
/>
Standard Android
- Basic
- Activities
- Fragments (deprecated)
- Navigator (like flutter and react) in googles Architecture pattern/
solution
18