Community Comment

Overview

This sample demonstrates how to develop a community comment UI that can be deployed across devices. This sample covers bar-type phones, foldable devices, tablets, and PCs. In addition, a three-layer architecture is used to organize the code project, and the adaptive layout and responsive layout are combined to build a complete community comment experience, covering the follow page, hot topics, social details, and image details.

Preview

Widescreen Foldable Outer Screen Bar-Type Phone Foldable
Tablet PC

How to Use

  1. Install and open the application on a bar-type phone, bi-fold device, widescreen foldable device, tablet, or PC. The responsive layout and adaptive layout are used to display different effects on the application pages for different devices.
  2. The Following page shows the waterfall layout of posts of the authors you have followed. The follower list is displayed on the left (large-screen devices).
  3. The hot topics page displays real-time posts. The post widget is displayed on the left of the large screen, and the comment area is displayed on the right.
  4. Tap the post widget to go to the community details page, where the author information and images are displayed.
  5. Tap an image to go to the image details page, where you can view the full image.
  6. Switch between the home page, hot topics, video, and personal center at the bottom.

Project Directory

├──common
│  └──commonmulticommunityapplication                                     
│     └──src/main
│        ├──ets
│        │  ├──components                     // Common components
│        │  ├──constants                      // Common constants
│        │  ├──model                          // Common model
│        │  ├──utils                          // Utilities
│        │  └──view                           // Common service components of features
│        └──resources                         // Public resources
├──features                                   
│  ├──commoncommunityui                       // Common service component module of products
│  │  └──src/main
│  │     ├──ets
│  │     │  ├──view                           // Common service components of products
│  │     │  └──viewmodel                      // Common view model of products
│  │     └──resources                         // Static routing table resources
│  ├──contentcommunity                        // Content community module
│  │  └──src/main
│  │     ├──ets
│  │     │  ├──model                          // Post data model
│  │     │  ├──view                           // Post component
│  │     │  └──viewmodel                      // Post view model
│  │     └──resources                         // Post module resources
│  └──socialcommunity                         // Social community module
│     └──src/main
│        ├──ets
│        │  ├──model                          // Follower/Comment data model
│        │  ├──view                           // Follower/Comment component
│        │  └──viewmodel                      // Follower/Comment view model
│        └──resources                         // Social module resources
├──product                                    
│  ├──default                                 // Mobile phone/Tablet
│  │  └──src/main
│  │     ├──ets
│  │     │  ├──entryability                   // Entry ability
│  │     │  ├──entrybackupability             // Custom extension ability for application data backup and restoration
│  │     │  └──pages                          // Entry page
│  │     └──resources                         // Resource file
│  └──pc                                      // PC
│     └──src/main
│        ├──ets
│        │  ├──pages                          // Entry page
│        │  ├──pcability                      // Entry ability
│        │  └──pcbackupability                // Custom extension ability for application data backup and restoration
│        └──resources                         // Resource file
└──oh-package.json5                           // Project dependency declaration

How to Implement

  1. Page structure
Version 6.0.2(22) 6.1.0(23)
Root container Tabs are nested within a Navigation component. One NavPathStack component is used to manage all page routes. HdsTabs is nested within an HdsNavigation component. One NavPathStack component is used to manage all page routes.
  1. Use @Env(SystemProperties.BREAK_POINT) to listen for system breakpoint changes. Dynamically adapt UIs and dynamically change the single-column or split-column layout of the Navigation component.
  2. Use expandSafeArea to adapt to immersive display.
  3. Use the MVVM architecture. The Model layer defines data APIs, the ViewModel layer processes the service logic, and the View layer manages the UI display.
  4. Use WaterFlow to implement the waterfall layout of posts, which adapts to different screen sizes.
  5. Use SideBarContainer to implement the sidebar layout on large-screen devices.

Required Permissions

N/A

Constraints

  1. This sample is only supported on devices running standard systems, including bar-type phones, bi-fold devices (Mate X series), widescreen foldable devices, tri-fold devices, tablets, and PCs/2-in-1 devices.
  2. The HarmonyOS version must be HarmonyOS 6.0.2 Release or later.
  3. The DevEco Studio version must be DevEco Studio 6.1.0 Release or later.
  4. The HarmonyOS SDK version must be HarmonyOS 6.1.0 Release SDK or later.