Giter VIP home page Giter VIP logo

pivot_chat's Introduction

pivot_chat

Pivot Studio 打造的聊天软件。

Getting Started

Set up your environment

Fork the xhzq233/pivot_chat repo into your own GitHub account.

Clone the forked repo locally using the method of your choice. GitHub Desktop is simplest.

If you cloned the repo using SSH, you'll need to configure the upstream remote for xhzq233/pivot_chat. This will allow you to sync changes made in xhzq233/pivot_chat with the fork:

  • cd pivot_chat
  • Specify a new remote upstream repository (xhzq233/pivot_chat) that will be synced with the fork. SSH: git remote add upstream [email protected]:xhzq233/pivot_chat.git
  • Verify the new upstream repository you've specified for your fork. git remote -v

Then you can commit and push your changes to your forked repo and create a pull request to xhzq233/pivot_chat.

let's start coding🚀!

Set up your editor

dart format change to -l120

Screenshot 2023-07-09 at 15.51.34

Dependencies

项目结构

  • lib/theme.dart:主题配置,设计给出
  • lib/assets.dart:资源文件,包括图片、颜色、字体等,如 const kPCLogo = 'assets/images/logo.png'
  • lib/widget: 通用组件,以PC开头,代表Pivot Chat,如PCNetworkImage
  • lib/manager: 通用管理类,以PC开头,如PCImageCacheManager
  • lib/util: 通用工具类,以PC开头,如PCImageUtil
  • lib/pages/xxx: 各个页面以及各自需要的私有model

Note: 以下为示例

  • lib/pages/login: 页面,以PC开头,类名为PCLoginPage
    • lib/pages/login/pc_login_page.dart: 页面的bloc
    • lib/pages/login/pc_login_model.dart: 页面的model,如PCLoginModel
    • lib/pages/login/widgets/xxx_widget.dart: 页面的组件,一般不需要导出,以_开头,如_PCLoginButton,以part形式导入到page.dart中

WIP

module模板

modules/widget: 更加通用的组件,可跨项目使用,俗称轮子,自己按照功能命名

modules/util: 同上

项目规范

文件命名

  • 文件名使用小写字母,单词之间使用下划线分割,并且将其主要类名写全,如:image_cache_manaer.dart
  • 类名使用大驼峰命名法,如:ImageCacheManager
  • 文件内私有const/final变量,以_开头,如:const _kDefaultImageSize = 100.0;,其中加k前缀代表Key,注意判断该变量是否需要其他地方使用,需要使用的话就不要加_前缀,并且要归类到constants.dart文件中

代码规范

  • 代码缩进使用2个空格
  • 要换行的地方,必须加上comma ,,如:
PCNetworkImage(
  imageUrl: 'https://picsum.photos/250?image=9',
  width: 100,
  height: 100,
),

// or else
PCNetworkImage(imageUrl: 'https://picsum.photos/250?image=9', width: 100, height: 100)

log规范

什么地方应该打日志?

  • 业务关键路径,例如支付流程中,用户点击支付请求->客户端请求Apple支付->Apple回调请求结果->请求业务后台->业务后台回包->调用苹果服务完成支付,这里的每一步都应该打日志(并且需要带上关键的参数),这样才能在用户反馈问题的时候快速缩小排查范围(例如发现后台回包报错,在确认请求体没有问题的情况下可以快速交给后台排查),在满足下面要求的前提下日志点越丰富越好。
  • 复杂逻辑实现中,例如输入框的状态转换
  • 用户行为操作,例如点击按钮、切换语言、退出登录等等,建议把所有用户操作点击行为触发处都加上日志,可以复现用户操作步骤,从而本地复现问题(双击、快速切换之类的问题;“明明没有删除”之类的问题)

什么地方不应该打日志?

  • 超高频调用中(最典型的,Flutter的build方法)
    • 如果实在要打,在某个值变化时才打,或者加频控
  • 用户敏感信息(聊天记录,手机号,密码等)

打什么样的日志

  • TAG
  • 注意区分等级verbose/debug/info/warning/error 每一级都有自己的作用,其中verbose和debug发布时不会输出,所以仅本地调试的日志一定不能高于info级别
  • catch的error信息一定要带上exception以及堆栈
  • 不要打大片大片的日志(例如把后台返回的复杂json直接输出并不合适,会非常影响查问题的体验)

Debug

  • 使用debugPrint打印你在修复bug时的日志,而不是print,因为debugPrint可以在release模式下不打印日志,修复完了记得要去掉
  • 尽量使用assert来保证你所认为的代码的正确性,例如:
// here i assume the image size must be greater than 0
assert(_kDefaultImageSize > 0);

Commit规范

  • Commit提交前确保能编过(特殊情况合作解决编译问题除外)
  • Commit粒度尽量细,尽量不要出现特大Commit
  • 养成勤拉分支的习惯,做新的东西拉新的分支;

Ignore

默认ignore了**/*.g.dart,避免代码提交时冲突,副作用是需要手动运行dart pub run build_runner build来生成代码

状态管理

bloc与manager的区别

一个在widget树中,一个不在

为什么使用flutter_bloc

  • 树状结构,契合Flutter的Widget树

编写网络API

见/lib/manager/network/pc_network_manager.dart中的example

pivot_chat's People

Contributors

xhzq233 avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.