mirror of
https://github.com/fjvallarino/monomer.git
synced 2024-11-10 11:21:50 +03:00
Add outline of tutorials and installation
This commit is contained in:
parent
837ce548a5
commit
4a7a3c742d
81
assets/stack-templates/simple.hsfiles
Normal file
81
assets/stack-templates/simple.hsfiles
Normal file
@ -0,0 +1,81 @@
|
||||
{-# START_FILE stack.yaml #-}
|
||||
# For advanced use and comprehensive documentation of the format, please see:
|
||||
# https://docs.haskellstack.org/en/stable/yaml_configuration/
|
||||
resolver: lts-17.6
|
||||
|
||||
packages:
|
||||
- .
|
||||
|
||||
extra-deps:
|
||||
- git: https://github.com/fjvallarino/nanovg-hs
|
||||
commit: b79fa2bfd60e26f49eea6fcafd668396835714b4
|
||||
- git: https://github.com/fjvallarino/monomer
|
||||
commit: d8e6f967f2d413560386a926ee5e0a803a251f68
|
||||
|
||||
{-# START_FILE package.yaml #-}
|
||||
name: {{name}}
|
||||
version: 0.1.0.0
|
||||
#synopsis:
|
||||
#description:
|
||||
homepage: https://github.com/{{github-username}}{{^github-username}}githubuser{{/github-username}}/{{name}}#readme
|
||||
license: BSD3
|
||||
author: {{author-name}}{{^author-name}}Author name here{{/author-name}}
|
||||
maintainer: {{author-email}}{{^author-email}}example@example.com{{/author-email}}
|
||||
copyright: {{copyright}}{{^copyright}}{{year}}{{^year}}2019{{/year}} {{author-name}}{{^author-name}}Author name here{{/author-name}}{{/copyright}}
|
||||
category: {{category}}{{^category}}Web{{/category}}
|
||||
extra-source-files:
|
||||
- README.md
|
||||
|
||||
dependencies:
|
||||
- base >= 4.7 && < 5
|
||||
|
||||
executables:
|
||||
{{name}}:
|
||||
source-dirs: src
|
||||
main: Main.hs
|
||||
|
||||
{-# START_FILE Setup.hs #-}
|
||||
import Distribution.Simple
|
||||
main = defaultMain
|
||||
|
||||
{-# START_FILE src/Main.hs #-}
|
||||
module Main where
|
||||
|
||||
main :: IO ()
|
||||
main = do
|
||||
putStrLn "hello world"
|
||||
|
||||
{-# START_FILE README.md #-}
|
||||
# {{name}}
|
||||
|
||||
{-# START_FILE LICENSE #-}
|
||||
Copyright {{author-name}}{{^author-name}}Author name here{{/author-name}} (c) {{year}}{{^year}}2021{{/year}}
|
||||
|
||||
All rights reserved.
|
||||
|
||||
Redistribution and use in source and binary forms, with or without
|
||||
modification, are permitted provided that the following conditions are met:
|
||||
|
||||
* Redistributions of source code must retain the above copyright
|
||||
notice, this list of conditions and the following disclaimer.
|
||||
|
||||
* Redistributions in binary form must reproduce the above
|
||||
copyright notice, this list of conditions and the following
|
||||
disclaimer in the documentation and/or other materials provided
|
||||
with the distribution.
|
||||
|
||||
* Neither the name of {{author-name}}{{^author-name}}Author name here{{/author-name}} nor the names of other
|
||||
contributors may be used to endorse or promote products derived
|
||||
from this software without specific prior written permission.
|
||||
|
||||
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
|
||||
"AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
|
||||
LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
|
||||
A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
|
||||
OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
|
||||
SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
|
||||
LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
|
||||
DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
|
||||
THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
|
||||
(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
|
||||
OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
96
docs/tutorials/00-setup.md
Normal file
96
docs/tutorials/00-setup.md
Normal file
@ -0,0 +1,96 @@
|
||||
# Installation
|
||||
|
||||
## Stack
|
||||
|
||||
In case you dont have it installed in your system, you should visit
|
||||
[Stack's](https://docs.haskellstack.org/en/stable/install_and_upgrade/) website
|
||||
and follow the appropriate installation method for your OS. If you are on
|
||||
Linux or macOS, you will be provided with a shell command, while if you are on
|
||||
Windows a regular installer is available.
|
||||
|
||||
## SDL2
|
||||
|
||||
### macOS
|
||||
|
||||
```bash
|
||||
brew install sdl2
|
||||
```
|
||||
|
||||
In case you don't have Homebrew installed, visit [Homebrew](https://brew.sh)
|
||||
|
||||
### Linux
|
||||
|
||||
#### Ubuntu
|
||||
|
||||
```bash
|
||||
sudo apt-get install -y libsdl2-dev
|
||||
```
|
||||
|
||||
#### Arch
|
||||
|
||||
```bash
|
||||
pacman -S sdl2
|
||||
```
|
||||
|
||||
### Windows
|
||||
|
||||
**Pending, check below url**
|
||||
https://www.reddit.com/r/haskell/comments/cjv2hh/help_setting_up_sdl2_on_windows/
|
||||
|
||||
## Clone the sample project
|
||||
|
||||
```bash
|
||||
git clone https://github.com/fjvallarino/monomer-sample.git
|
||||
```
|
||||
|
||||
## Build the project
|
||||
|
||||
```bash
|
||||
stack build
|
||||
```
|
||||
|
||||
## Development mode
|
||||
|
||||
Since compilation times can be annoying, I personally prefer to rely on `ghcid`
|
||||
for a nicer development experience. First, you need to install it:
|
||||
|
||||
```bash
|
||||
stack install ghcid
|
||||
```
|
||||
|
||||
If you use Visual Studio Code, you can also use this very nice extension:
|
||||
|
||||
```
|
||||
https://marketplace.visualstudio.com/items?itemName=ndmitchell.haskell-ghcid
|
||||
```
|
||||
|
||||
With this, you will be running your application in interpreted mode (`ghcid`
|
||||
under the hood uses `ghci`), allowing you to make changes and test them almost
|
||||
immediately.
|
||||
|
||||
## Notes for macOS users
|
||||
|
||||
If you have a discrete GPU, you may want to copy Info.plist into the bin directory
|
||||
the build command shows. It will be something like:
|
||||
|
||||
```bash
|
||||
$HOME/.../monomer-sample/.stack-work/install/x86_64-osx/......../8.10.4/bin
|
||||
```
|
||||
|
||||
By doing this, you will be using the integrated GPU instead of the discrete one.
|
||||
This provides faster startup, better battery life and it will work just fine for
|
||||
most UIs.
|
||||
|
||||
Further, you may want to do this for your local stack install directory, since
|
||||
you'll be using ghcid and Info.plist needs to be in the directory where the
|
||||
executable is located. The path is usually:
|
||||
|
||||
```bash
|
||||
$HOME/.local/bin
|
||||
```
|
||||
|
||||
### ghcid
|
||||
|
||||
The sample project includes custom .ghci and .ghcid files. The most important
|
||||
change in .ghci is for Mac users, since Mac does not allow rendering to happen
|
||||
outside the main thread (by default `ghci` spawns a thread of user code).
|
32
docs/tutorials/outline.md
Normal file
32
docs/tutorials/outline.md
Normal file
@ -0,0 +1,32 @@
|
||||
- Create initial project from stack template
|
||||
- Install stack
|
||||
- Install SDL library dependency
|
||||
- Do we need something for nanovg?
|
||||
- Clone sample project
|
||||
- Compile and run
|
||||
- Show how to use ghcid for faster dev cycle
|
||||
- Basics of UI building and event handling
|
||||
- Basic layout widgets (stack and grid).
|
||||
- Basic widgets: label, button, spacer, checkbox and radio.
|
||||
- Event handling: model updates.
|
||||
- Running tasks
|
||||
- Lifecycle
|
||||
- Merging.
|
||||
- Keys, paths, widgetIds.
|
||||
- Some more widgets: textField, image, scroll, keystroke.
|
||||
- Some kind of search and show results.
|
||||
- App config
|
||||
- Styling
|
||||
- Resizing fonts, font name, changing colors.
|
||||
- Use box, slider, dropdown, colorPicker.
|
||||
- Quirks of positioning, modifying sizeReqs, etc.
|
||||
- Composite
|
||||
- Could reuse example from Running tasks
|
||||
- Widgets: zstack.
|
||||
- Use dialogs.
|
||||
- Running producers
|
||||
- Consume a streaming data source.
|
||||
- Widgets: Draggable, DropTarget, animations.
|
||||
- Sending messages.
|
||||
- Custom widget
|
||||
- Merging, event handling, sizeReq, rendering.
|
3
tasks.md
3
tasks.md
@ -663,9 +663,12 @@
|
||||
- Rename LeftBtn -> BtnLeft
|
||||
|
||||
Next
|
||||
- Rethink Model/Event naming in EventResponse
|
||||
- Create user documentation
|
||||
- Overview of the library
|
||||
- Tutorials
|
||||
- Function for setting focus should be in Utils.
|
||||
- Default theme should be usable (scroll, etc)
|
||||
- Create ContextMenu (could work similarly to Tooltip)
|
||||
- Add context button in wenv/config (similar to main button)
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user