• Stars
    star
    238
  • Rank 168,413 (Top 4 %)
  • Language
    Swift
  • License
    Apache License 2.0
  • Created about 2 years ago
  • Updated 4 months ago

Reviews

There are no reviews yet. Be the first to send feedback to the community and the maintainers!

Repository Details

❤️ SwiftUI All In One Example.

AwesomeSwift -- SwiftUI 综合示例、样板工程

1、简介

该项目是在阅读了多个开源项目源码之后沉淀而成,用来演示 SwiftUI 的控件和各种功能组件的使用,同时包含了实际开发过程中可能使用到的各种必备的组件,比如 Lottie、RSwift、崩溃统计等等,适合想要学习 Swift 开发的的新手同学。

2、技术示范

该项目支持最低版本 iOS 为 14,使用 CocoaPods 作为构建工具。下面是范例清单。

2.1 SwiftUI 内置控件

  • Text 的示范:TextDemoView
    • Text:普通文本
    • Link:可以点击的链接
  • 按钮的示范:ButtonDemoView
    • Button:常规按钮以及常用的背景实现示范
    • Toggle:开闭按钮
    • Slider:滑块按钮
    • Stepper:步进器
    • NavigationLink:跳转按钮
  • 输入框的示范:TextFieldDemoView
    • TextField:单行输入
    • TextEditor:多行输入
    • SecureField:密码输入
  • 图片控件 Image 的示例:ImageDemoView
    • Image:使用 UIImage、系统内置图片、缩放技巧
    • 自定义形状:LinearGradient、RoundedRectangle、Capsule 和 Circle
  • 表单的示例:FormDemoView
  • 对话框和弹出:PopupDemoView
    • ActionSheet:底部弹出的标准对话框
    • Alert:中间弹出的标准对话框
    • Popover:可自定义弹出浮层,但是会让底部对话框缩小
    • Picker:局部弹出的列表选择框,支持多种样式
    • DatePicker:日期和时间选择
  • 动画的示例:AnimationDemoView
    • DragGesture:手势拖动
    • withAnimation:淡入淡出等效果
    • simultaneousGesture:持续手势处理
    • highPriorityGesture:高优先级手势
    • ViewModifier:自定义变换
  • 布局示例:LayoutDemoView
    • 布局控件:ScrollView、HStack、VStack 和 ZStack
    • alignment:对齐属性
    • multilineTextAlignment:多行文本对齐属性
    • alignmentGuide:对齐属性微调
  • SwiftUI 中使用 UIKit 控件示范:SegmentedViewDemo
    • 继承 UIViewRepresentable 并实现 makeCoordinator、makeUIView 和 updateUIView 三个方法

2.2 开发必备的非官方控件

2.3 常用页面结构示例

2.4 常用业务和功能模块

2.5 数据存储和数据交互

数据存储

数据交互

2.6 环境和开发框架

除了上述控件和页面框架等基本单元,作为一个成熟的产品,对应用的稳定性和开发的高效也是有要求的,这要求我们对开发环境进行基础的设置。所以,这里列举的是一些必要的可以提升开发效率和应用稳定性的工具。

  • firebase-ios-sdk:应用崩溃监控,用来上报程序崩溃日志和进行简单的用户统计
    • 集成说明:Get started with Firebase Crashlytics
    • Step 1: 按照官网的说明,添加 Firebase Crashlytics 依赖
    • Step 2: 修改 Build Settings,输出 dSYM 文件
    • Step 3: 修改 Build Phase,添加上传 dSYM 文件的逻辑
    • Step 4: 添加崩溃,然后测试,测试的时候需要构建完成并 Stop 再测试,因为处于 debug 状态的时候,xcode 会拦截崩溃
  • R.swift:用来以类似于 Android 的 R 文件的方式引用项目里的资源,比直接使用字符串应用的方式不容易出错
  • Then:语法躺,类似于 Kotlin 的 apply 的效果,但是似乎只对 UIKit 有效
  • CocoaPods:项目的构建工具和依赖管理工具
    • 创建 Podfile 文件
    • 执行 pod install 命令
  • SwiftPackageManager:项目的依赖管理工具

2.7 综合示例

WanAndroid 示例工程

  • 项目地址:WanAndroid
  • 该项目基于 Alamofire 实现网络请求
  • 该项目基于 HandyJSON 实现 JSON 数据解析
  • 该项目基于 Kingfisher 实现网络图片加载
  • 该项目基于 MVVM 设计和开发

License

Copyright (c) 2022-present WiSH

Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at

   http://www.apache.org/licenses/LICENSE-2.0

Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.

More Repositories

1

MarkNote

An open sourced markdown note-taking application for Android.
Java
890
star
2

Compressor

An easy to use image compress library for Android.
Kotlin
600
star
3

iCamera

Yet another camera library for Android.
Kotlin
462
star
4

arch-android

Type based Jetpack MVVM library.
Kotlin
220
star
5

Android-references

[DEPRECATE] 请访问新项目 https://github.com/Shouheng88/Android-VMLib 👏 Android 示例程序:MVP, MVVM, 组件化, AndroidX, ARouter, RxJava, EventBus, ButterKnife, 视频播放, 视频直播, 网络访问, 布局和控件整理等
Java
214
star
6

Android-notes

[DEPRECATED] Articles, notes, interview questions and resources management for Android.
156
star
7

OmniList

开源的时间管理App,基于Material Design设计
Java
93
star
8

AndroidStartup

An Android startup jobs sceduler.
Kotlin
51
star
9

EasyMark

The markdown parser, editor and viewer for Android which is rather easy to integrate.
Java
47
star
10

autopackage

An Android auto package script.
Python
38
star
11

AndroidTools

🔧 Many useful tools for Android development, adb wrapper, smali, languages etc.
Python
38
star
12

xDialog

An beautiful and easy to use dialog library for Android.
Kotlin
24
star
13

LeafNote-Community

A platform to share information and materials about Leaf Note.
18
star
14

xAdapter

A convenient way to use Adapter in RecyclerView based on Kotlin DSL and BRVAH.
Kotlin
17
star
15

Seed

Booster is a SpringBoot generator used to genrate everything for your Springboot App to accelate your server development.
Java
13
star
16

products-spider

JD & TB products spider.
Python
11
star
17

jarjar

一个 Jar 瘦身工具,用来从 jar 文件中移除你调用不到的类文件。可以用来做 Android 包体积优化优化。
Python
10
star
18

the-chinese-city-rank

中国城市排行,选择更适合你定居的城市
Python
3
star
19

Shouheng88

3
star
20

Springcloud-references

the basic show cases of spring cloud development
Java
2
star