RoomTime
RoomTime is a bundle of tools developed in my app RoomTime Lite
. (? RoomTime Lite is still in development)
Requirements
- iOS 13 or newer
- tvOS 13 or newer
- watchOS 6 or newer
- macOS is not supported currently
Installation
- In Xcode project, navigate to File -> Swift Packages -> Add Package Dependency... .
- Paste
https://github.com/RainbowTalaxy/RoomTime
and click Next.
Usage
TextArea
TextArea
uses like SwiftUI's TextEditor
, but not supports internal modifiers such as .font(_)
.
AutoWrap
AutoWrap
can let views wrap automaticly:
Markdown
Markdown
is a separate module, so you just need to import Markdown
.
Here is a brief usage:
Syntax support
- header 1-6
- quote
- order or unorder list
- indent or block code
- border
- table
- more in development ...
Here gives a text which shows what Markdown
supports:
# Heading 1
## Heading 2
### Heading 3
#### Heading 4
##### Heading 5
###### Heading 6
# Quote
> An apple a day keeps the doctor away.
>> Quote can also be nested,
> > > and spaces are allowed bewteen arrows.
# List
* Unorder list
- apple
+ banana
* strawberry
* Order list
1. eat
2. code!
3. sleep
You can also specify the offset:
11. eat
2. code!
3. sleep
# Code
Supports indent code:
var name = "Talaxy"
and code block syntax:
```swift
// example
struct Demo: View {
var body: some View {
Text("Hello world!")
}
}
```
# Border
---
* * *
__ ___ ____
# Table
Alignment syntax is supported.
| Property | Type | Description |
|:-------- |:------:| -----------:|
| title | String | The title of the news. |
| date | Date | The date of the news. |
| author | String | The author ... |
Mechanism
Markdown
uses Resolver
to convert text into markdown elements.
Resolver
has two rendering stages: "Spliting" and "Mapping" :
In "Spliting" stage, Resolver
splits text into Raw
s by SplitRule
instances orderly.
Here is the definetion of the Raw
:
lock
tells theResolver
whether wants to be splited by further split rules.text
contains the text itself.type
is for "Mapping" stage.
In "Mapping" stage, Resolver
converts Raw
s into Element
objects.
Extend syntax supports
With Markdown
rendering mechanism, you can customize your rendering rule.
For Example, if you want to highlight lines which starts with $
sign, you can implement by steps below:
First, create render rule:
Second, define DollarLine
view:
Third, configure the Resolver
:
Finally, use Markdown
and extend element view:
Here is the output: