LAYOUT OCH INTERAKTION 1 Agenda Frgor Layout Android - - - PowerPoint PPT Presentation

layout och interaktion
SMART_READER_LITE
LIVE PREVIEW

LAYOUT OCH INTERAKTION 1 Agenda Frgor Layout Android - - - PowerPoint PPT Presentation

LAYOUT OCH INTERAKTION 1 Agenda Frgor Layout Android - standard Flexbox Flutter Hantera interaktion Lyssnare Organisation Cohesion och Coupling Komplexa komponenter MVC ,MVP


slide-1
SLIDE 1

LAYOUT OCH INTERAKTION

1

slide-2
SLIDE 2

Agenda

  • Frågor
  • Layout
  • Android - standard
  • Flexbox
  • Flutter
  • Hantera interaktion
  • Lyssnare
  • Organisation
  • Cohesion och Coupling
  • Komplexa komponenter
  • MVC ,MVP ,MVVM
  • 2
slide-3
SLIDE 3

Standard Android layouts

  • ViewGroup - a View that supports adding child views
  • LinearLayout
  • Left-to-Right or Top-to-Bottom
  • FrameLayout
  • Designed for a single View child
  • RelativeLayout
  • Views placed in relations to each other or the parent
  • GridLayout
  • Rows and Columns
  • ConstraintLayout
  • RelativLayout on steroids

3

slide-4
SLIDE 4

Flexbox layout

  • Multiple properties are used together in order to use Flexbox

layout

  • Some properties are set on the container (parent, flex container)
  • Some properties are set on the elements in the container (children,

flex items)

  • https://developer.mozilla.org/en-US/docs/Web/CSS/CSS_Flexible_Box_Layout
  • https://css-tricks.com/snippets/css/a-guide-to-flexbox/
slide-5
SLIDE 5

Main Axis and Cross Axis

slide-6
SLIDE 6

Some parent container properties

  • display: flex
  • flex-direction: row | row-reverse | column | column-reverse
  • flex-wrap: nowrap | wrap | wrap-reverse
  • justify-content: flex-start | flex-end | center | space-between
  • align-items: stretch | flex-start | flex-end | center | baseline
  • flex-flow: <flex-direction> <flex-wrap>
slide-7
SLIDE 7

flex-direction and flex-wrap

slide-8
SLIDE 8

justify-content

slide-9
SLIDE 9

align-items and align-content

slide-10
SLIDE 10

Properties set on children

  • order: <integer>
  • flex-grow: <positive number>
  • flex-shrink: <positive number>
  • flex-basis: <width/height>
  • align-self: auto | flex-start | flex-end | center | baseline | stretch;
  • flex (see reference documentation)
slide-11
SLIDE 11
  • rder
slide-12
SLIDE 12

flex-grow and flex-shrink

slide-13
SLIDE 13

align-self

slide-14
SLIDE 14

Layout in Flutter

  • Based on Widgets in rows and columns
  • Everything is a widget (almost)
slide-15
SLIDE 15
slide-16
SLIDE 16

Layout widgets

  • Containers are layout widgets
  • https://flutter.dev/docs/development/ui/widgets/layout
slide-17
SLIDE 17

Widget Messages

17

  • Messages from widgets to your code

– Information about a change in state – Messages of user generated actions

  • Mouse movement, keyboard action
  • Touch , Sensors
  • Widgets has a set of Messages (zero or more) you

choose which you care about

slide-18
SLIDE 18

Widget Messages

18

  • Messages passed though callback functions
  • You registers yourself with component using listeners

– android : setOnClickListener

  • Receive notification

  • nClick(View v)
slide-19
SLIDE 19

Listeners

19

code Your code Button/Widget

add_A_Listener(this) callback_function(Event)

slide-20
SLIDE 20

Button-click kotlin

20

button.setOnClickListener{ counter++ textView.text = "Click counter : $counter" } button.setOnClickListener(object: View.OnClickListener {

  • verride fun onClick(v: View?) {

counter++ textView.text = "Click counter : $counter" v?.setBackgroundColor(Color.MAGENTA) } })

slide-21
SLIDE 21

Button-click flutter

21

FlatButton( child: Text('I am FlatButton'),

  • nPressed: (){

print('You tapped on FlatButton'); }, ),

Flutter has multiple Button widgets

slide-22
SLIDE 22

Button-click React Native

22

<Button

  • nPress={() => {

alert('You tapped the button!'); }} title="Press Me" /> Flutter has multiple Button widgets

slide-23
SLIDE 23

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

23

slide-24
SLIDE 24

Cohesion and Coupling

24

slide-25
SLIDE 25

Model-View-Controller

25

slide-26
SLIDE 26

Model-View-Presenter MVP

26

slide-27
SLIDE 27

Model View ViewModel MVVM

27