My history of the implementation of the offline Habr application

Creating your own Habr application has already become a tradition among Habruzers. I decided to keep up and make my own.





In this article, I will first of all talk about how the client for Habr was created, architectural and technical solutions, their prerequisites and analysis, what difficulties were there, and last of all about the functionality of the application.





Background

It all started with a friend's suggestion to try Flutter, but I didn't mind.





, ? , , - ( ).





React+TypeScript VanilaJs, React Flutter.





, html , โ€” , โ€œโ€: html , - web-view. , .





- . , Dart , , ( Flutter : , .. , ui ).





:





  • ui





  • habr-storage - , , .





  • habr-api - http .





, . MVVM.





Here I tried to schematically depict the architecture

UI

API html js . html . 





html Flutter, , : 





  1. web-view





  2. ( Flutter)





, , React Native, .





The main feed that the user encounters when starting the application

HTML

, , . iframe, , web-view. , , , . , .





:

















, .. .





html , , . 





. html, div, . , , .. html, css . , - , " ".





html :





<div class="spoiler" role="button" tabindex="0">
  <b class="spoiler_title"> </b>
  <div class="spoiler_text"> </div>
 </div>
      
      



, details - .





2 :





  1. html









html5. , :





  • ( )









  •  





  • ( /)













  • Iframe













- . , .





Flutter RecyclerView Android, ListView. ( ), .





Displaying Comments

, : . - - , .. .





First version with tree view

, - , , - , "" . , ui , ListView , N , , N .





Current implementation with "flat" display
ยซยป

, 1000 - , - .





. , . , . , , - ListView "" , . , .





Habr-API

m.habr.com/kek/v2/





API:













, , , , , , , - , , . , . โ€“ API .   





, API - . , API , . - .





Habr-Storage

Moor (Room, Dart) SQLite, - , . โ€“ Hive, NoSQL Key-Value , . , ( ), , .





SQLite html , (, ) , Hive. . 





SQLite. . url, , path . Path - url` . :





path = str(hash(url)) + str(datetime.now().millisecondsSinceEpoch)
      
      



Isolates

Dart , , , web-workers Isolate. , HTTP , JSON, , Flutter. 





- , -.





: Flutter . compute. 





โ€“ , , . :





  1. . compute, , , , . 





  2. . , , , middle, , , , , . . 





:

















For the parsing and preprocessing operation, I still use the compute method.





Conclusion

This is basically all that I would like to tell about the internal structure of the application. 





I did not intend this post as an advertisement, but the desire to poke the application and see the code may arise, so I attach a link to github .





And then a couple of screenshots of the application:








All Articles