{"_id":"56194d8088fdee0d00fb9c76","__v":3,"parentDoc":null,"project":"552829408962f339009a678d","user":"55282916d9e1db2d00cd923c","version":{"_id":"552829408962f339009a6790","project":"552829408962f339009a678d","__v":26,"createdAt":"2015-04-10T19:49:20.516Z","releaseDate":"2015-04-10T19:49:20.516Z","categories":["552829418962f339009a6791","55284ed68962f339009a67e1","55286c73391a362500d9b3f4","552918f6b316811900149f59","5529b255d739240d00a3483e","553287590a578a0d008d4ff5","55329385e7d1fa0d003fc946","5550b55200420e0d00d1312f","55525fca953c9c0d00f507d7","559199695631432f002d358a","559d8d96980b801700d5ec7e","55c5e833cccdeb2d004e24b9","55d76504f662951900fc0e7d","55ea213cc62aa02f008229cd","56157b750f5ed00d00483dd8","561981fbac0924170069f4e8","561b8b1ea430930d0037ea67","563417428b86331700b488ca","56cd785bface161300dae0ec","56cdcc6e70db8a15006395f4","56cdf1b749abf10b0036a34a","56cedc8ce50c9c1b00830423","56e97ba8d825061900d1ac83","570d505228e6900e00477229","573614ca2ab52e1700c8e851","57d556a2496a3117004d70cf"],"is_deprecated":false,"is_hidden":false,"is_beta":false,"is_stable":true,"codename":"","version_clean":"1.0.0","version":"1.0"},"category":{"_id":"56157b750f5ed00d00483dd8","version":"552829408962f339009a6790","__v":9,"pages":["56157bbcf2d81d0d006c895b","5618eb1bf908460d00daf40e","561949613217dd0d003ab868","561949fced64430d0063f0bb","56194d8088fdee0d00fb9c76","56cddce649abf10b0036a313","56cdded9e538330b0021ab24","56df63ef67ccff1700c99efa","56df659a723dd61700ea1481"],"project":"552829408962f339009a678d","sync":{"url":"","isSync":false},"reference":false,"createdAt":"2015-10-07T20:07:17.140Z","from_sync":false,"order":5,"slug":"ios-sdk","title":"iOS SDK"},"updates":[],"next":{"pages":[],"description":""},"createdAt":"2015-10-10T17:40:16.201Z","link_external":false,"link_url":"","githubsync":"","sync_unique":"","hidden":false,"api":{"results":{"codes":[]},"settings":"","auth":"required","params":[],"url":""},"isReference":false,"order":5,"body":"Actor uses a lot of optimizations for chat speed and on iOS layouting is performed in two phases. Measuring in background and layouting in main thread.\n\nFirst of all, you need to create subclass of AABubbleLayouter\n[block:code]\n{\n  \"codes\": [\n    {\n      \"code\": \"protocol AABubbleLayouter {\\n    func isSuitable(message: ACMessage) -> Bool\\n    func buildLayout(peer: ACPeer, message: ACMessage) -> ActorSDK.AACellLayout\\n    func cellClass() -> AnyClass\\n}\",\n      \"language\": \"swift\"\n    }\n  ]\n}\n[/block]\nFirst method - ```isSuitable``` - returns true if layouter support this kind of content.\nSecond one - ```buildLayout``` - calculates and measure layout for your cell. You can return ```AACellLayout``` instance or any subclass and store any preprocessed information in bubble. AACellLayout have ```height``` of cell, ```date``` of message (no need to cache date formatting code) and ```key```. Last one is useful when you need to change layout in time. Layout engine doesn't recalculate layout information for cell if key is not changed. If you want to update layout, just change ```key``` value and engine will recalculate layout. You can even change bubble cell class for this key (in other Layouter).\nLast method - ```cellClass``` - is ```AABubbleCell``` subclass for representing data.\n\nYou can use built-in bubble types, for example, you can easily implement your own layouter that will layout standard text cells.\n\nAfter this you can hack ActorSDK in delegate and place your layouter to right place. Layout Engine will ask one layout after other starting from 0 element while he finds suitable one.","excerpt":"Add new chat content for your app","slug":"customize-bubbles","type":"basic","title":"Customize chat bubbles"}

Customize chat bubbles

Add new chat content for your app

Actor uses a lot of optimizations for chat speed and on iOS layouting is performed in two phases. Measuring in background and layouting in main thread. First of all, you need to create subclass of AABubbleLayouter [block:code] { "codes": [ { "code": "protocol AABubbleLayouter {\n func isSuitable(message: ACMessage) -> Bool\n func buildLayout(peer: ACPeer, message: ACMessage) -> ActorSDK.AACellLayout\n func cellClass() -> AnyClass\n}", "language": "swift" } ] } [/block] First method - ```isSuitable``` - returns true if layouter support this kind of content. Second one - ```buildLayout``` - calculates and measure layout for your cell. You can return ```AACellLayout``` instance or any subclass and store any preprocessed information in bubble. AACellLayout have ```height``` of cell, ```date``` of message (no need to cache date formatting code) and ```key```. Last one is useful when you need to change layout in time. Layout engine doesn't recalculate layout information for cell if key is not changed. If you want to update layout, just change ```key``` value and engine will recalculate layout. You can even change bubble cell class for this key (in other Layouter). Last method - ```cellClass``` - is ```AABubbleCell``` subclass for representing data. You can use built-in bubble types, for example, you can easily implement your own layouter that will layout standard text cells. After this you can hack ActorSDK in delegate and place your layouter to right place. Layout Engine will ask one layout after other starting from 0 element while he finds suitable one.