Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Re Architecture SceneSequence #81

Closed

Conversation

crexista
Copy link
Owner

@crexista crexista commented Aug 21, 2017

Abstruct

  1. Scene, Scenario, Sequence are redesigned, and refactored
  2. Some new feature added.

Refactor

A. redefine deference screen and scene
Screen was just Scene's type erasure protocol
And, Screen had sendTransitionRequest and leaveFromCurrent.

but I redefine Screen and Scene as below.

  • Screen

    1. Just Display, like a plate.
    2. Screen has two status
    • activated
    • suspended
  • Scene

    1. Scene is transitionable screen.
    2. So, Scene has context and returnValue(when rewind)

So, Screen does not have sendTransitionRequest and leaveFromCurrent from now.
And, Scene has sendTransitionRequest and leaveFromCurrent insted of Screen.

B. SceneSequence separate to SceneCollection, ScreenContainer

SceneSequence become complex, so redesigned SceneSequence
So, SceneSequence become to extend SceneCollection and implement ScreenContainer

SceneCollection's job is stacking Scene and activate Scene
detail will be write later..

New Feature

  • Scene can define associeated Type ReturnValue
    ReturnValue is type of argument to previous scene when rewind to back scene.

    can use like this

    // on Fist Scene
    sendTransitionRequest(SampleRequest(value){ (result: String) in
      print(result)
    })
    
    // on Second Scene
    leaveFromCurrent(returnValue: String) // SampleRequest's ResultValue Type
  • SceneSequence can suspend.
    SceneSequence become to be able to suspend.
    suspended screen cannot sendTransitionRequest(if request is send, it will be ignored)

  • SceneSequenceBuilder added.
    SceneSequence's initial parameter is many.
    So SceneSequenceBuilder is maked.

    let builder = SceneSequence.builder(scene: scene, guide: rule)
                               .setup(UINavigationController(rootViewController: UIViewController()), with: false)
    sequence = builder.build(onInvoke: { (stage, scene) in
        stage.isNavigationBarHidden = true
        stage.pushViewController(scene, animated: true)
    }, onActive: { (stage, screens) in
        self.window?.rootViewController?.addChildViewController(stage)
        self.window?.rootViewController?.view.addSubview(stage.view)
    }, onSuspend: { (stage, screens) in
        stage.view.removeFromSuperview()
        stage.removeFromParentViewController()
    })
    
    sequence?.activate()

Breaking Change

  • SceneOperation's I/F is changed.

    old

    operation.at(Sample1BViewController.self) { (scenario) in
       scenario.given(SampleARequest.self, { Sample1AViewController() }) { (args) in
           args.stage.pushViewController(args.next, animated: true)
              return {
                 args.stage.popViewController(animated: true)
              }
           }
       }
    }

    new

    operation.at(Sample1BViewController.self) { (scenario) in
        scenario.given(SampleARequest.self, transitTo: { Sample1AViewController() }) { (args) in
            args.stage.pushViewController(args.next, animated: true)
               return {
                  args.stage.popViewController(animated: true)
               }
            }
        }
    }

kmhjs and others added 7 commits July 26, 2017 18:38
Abstract:

- Set type parameter name as "${Target}Type"
- Set type parameter name (declared with `associatedtype` ) as "${Target}"

Note:

- This commit will break following thing.
  - `ContextType` declared in `Scene` protocol.
    - `ContextType` must be replaced with `Context` .
Abstract:

- Expand few variable names
- Make variable name more clear
Abstract:

- Update `ContextType` to `Context`
Abstract:

- Adds test cases for SceneSequenceTest, SceneTest, ScreenTest
Abstract:

- Set type parameter name as "${Target}Type"
- Set type parameter name (declared with `associatedtype` ) as "${Target}"

Note:

- This commit will break following thing.
  - `ContextType` declared in `Scene` protocol.
    - `ContextType` must be replaced with `Context` .
Abstract:

- Expand few variable names
- Make variable name more clear
Now, `SceneSequence` cannot stop and maybe leak when dispose sub sequence.
So, I have to remodel `SceneSequence`

**UPDATE**

- When SceneSequence's `leave` is called, SceneSequence will be able to be disposed.
- SceneSequence's type generics `Context` is useless. So,  SceneSequence's type generics match with First Scene.
- SceneSequence's 'startWith' method is too difficult to use. if context is not set, SceneSequence refer to `self.context` .

**Breaking Change**
This commit has breaking change
- `SceanSequence`'s `startWith` method deleted. instead of that method, start(on ~

**Hankey Changes**
- SceneSequence override `leave`. But it is a update that we do not need.
- So, this hankey update will be fixed later(maybe #74 fixed)
@crexista crexista force-pushed the versions/0.4.0-SNAPSHOT/rearchitecture-sequence branch from ad7e9ac to a3dd964 Compare August 21, 2017 08:20
@crexista crexista added WIP and removed Maybe Later labels Aug 21, 2017
@crexista crexista force-pushed the versions/0.4.0-SNAPSHOT/rearchitecture-sequence branch from a3dd964 to c4283a2 Compare August 22, 2017 04:14
@crexista crexista removed the WIP label Aug 22, 2017
**Abstruct**

1. Scene, Scenario, Sequence are redesigned, and refactored
2. Some new feature added.

**Refactor**

**A. redefine deference screen and scene**
`Screen` was just Scene's type erasure protocol
And, `Screen` had `sendTransitionRequest` and `leaveFromCurrent`.

but I redefine `Screen` and `Scene` as below.

- Screen
  1. Just Display, like a plate.
  2. Screen has two status
    - activated
    - suspended

- Scene
  1. Scene is transitionable screen.
  2. So, Scene has context and returnValue(when rewind)

So, `Screen` does not have `sendTransitionRequest` and `leaveFromCurrent` from now.
And, `Scene` has `sendTransitionRequest` and `leaveFromCurrent` insted of `Screen`.

**B. SceneSequence separate to SceneCollection, ScreenContainer**

`SceneSequence` become complex, so redesigned `SceneSequence`
So, `SceneSequence` become to extend SceneCollection and implement ScreenContainer

SceneCollection's job is stacking `Scene` and activate `Scene`
detail will be write later..

**New Feature**

- `Scene` can define associeated Type `ReturnValue`
  ReturnValue is type of argument to previous scene when rewind to back scene.

  can use like this
  ```swift
  // on Fist Scene
  sendTransitionRequest(SampleRequest(value){ (result: String) in
    print(result)
  })

  // on Second Scene
  leaveFromCurrent(returnValue: String) // SampleRequest's ResultValue Type
  ```

- `SceneSequence` can suspend.
  `SceneSequence` become to be able to suspend.
  suspended screen cannot sendTransitionRequest(if request is send, it will be ignored)

- `SceneSequenceBuilder` added.
  `SceneSequence`'s initial parameter is many.
   So `SceneSequenceBuilder` is maked.

   ```swift
   let builder = SceneSequence.builder(scene: scene, guide: rule)
                              .setup(UINavigationController(rootViewController: UIViewController()), with: false)
   sequence = builder.build(onInvoke: { (stage, scene) in
       stage.isNavigationBarHidden = true
       stage.pushViewController(scene, animated: true)
   }, onActive: { (stage, screens) in
       self.window?.rootViewController?.addChildViewController(stage)
       self.window?.rootViewController?.view.addSubview(stage.view)
   }, onSuspend: { (stage, screens) in
       stage.view.removeFromSuperview()
       stage.removeFromParentViewController()
   })

   sequence?.activate()
   ```

**Breaking Change**
- `SceneOperation`'s I/F is changed.

   **old**

   ```swift
  operation.at(Sample1BViewController.self) { (scenario) in
      scenario.given(SampleARequest.self, { Sample1AViewController() }) { (args) in
          args.stage.pushViewController(args.next, animated: true)
             return {
                args.stage.popViewController(animated: true)
             }
          }
      }
  }
  ```
  **new**

  ```swift
  operation.at(Sample1BViewController.self) { (scenario) in
      scenario.given(SampleARequest.self, transitTo: { Sample1AViewController() }) { (args) in
          args.stage.pushViewController(args.next, animated: true)
             return {
                args.stage.popViewController(animated: true)
             }
          }
      }
  }
  ```
@crexista crexista force-pushed the versions/0.4.0-SNAPSHOT/rearchitecture-sequence branch from c4283a2 to bb5efce Compare August 22, 2017 04:15
@crexista
Copy link
Owner Author

this pull request to master.
that's mistake.
so close

@crexista crexista closed this Aug 22, 2017
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants