diff --git a/Dockerfile b/Dockerfile new file mode 100644 index 0000000..133c1b2 --- /dev/null +++ b/Dockerfile @@ -0,0 +1,23 @@ +FROM debian:stable + +WORKDIR /usr/vscode + +ENV ANDROID_HOME="/usr/lib/android-sdk" +# install Android sdk & cmdline tools without Android Studio +RUN apt-get update && \ + apt-get install -y wget tar xz-utils unzip git && \ + apt-get install -y android-sdk && \ + wget https://dl.google.com/android/repository/commandlinetools-linux-10406996_latest.zip && \ + unzip commandlinetools-linux-10406996_latest.zip && \ + mkdir -p "${ANDROID_HOME}/cmdline-tools/latest" && \ + mv cmdline-tools/* "${ANDROID_HOME}/cmdline-tools/latest" && \ + rm -rf cmdline-tools + +ENV PATH="${ANDROID_HOME}/cmdline-tools/latest/bin:${PATH}" +RUN yes | sdkmanager --licenses && sdkmanager --install "platforms;android-33" + +# download and extract to "flutter" folder +RUN wget https://storage.googleapis.com/flutter_infra_release/releases/stable/linux/flutter_linux_3.13.3-stable.tar.xz && \ + tar vxfo flutter_linux_3.13.3-stable.tar.xz + +ENV PATH="${PATH}:/usr/vscode/flutter/bin" diff --git a/README.md b/README.md index e0e62ce..b6ad5ae 100644 --- a/README.md +++ b/README.md @@ -1,39 +1,45 @@ -# Simple-POS - -### ❤️❤️ [Online Demo](https://tcd93.github.io/flutter-pos)❤️❤️ - -A mobile POS written in _Flutter_, suitable for small cafe/restaurant, fully offline. - -**Tested & printable on **Sunmi V1S** device.** - -![sunmi_v1s](.github/resource/print.jpg) - -**Support:** - -- Android -- Web (unable to print) -- English & Vietnamese (auto detect Locale) - ---- - -## Install & Run - -Get [flutter](https://flutter.dev/) 3.10 - -``` -flutter pub get -flutter run -``` - -**For web** -1. `flutter run -d chrome` - -**For Android** -**Requirement: JAVA sdk >=18** -1. `flutter run` - -## Testing -`flutter test` - -## TODO -- [ ] Remote printing? (via Bluetooth) +# Simple-POS + +### ❤️❤️ [Online Demo](https://tcd93.github.io/flutter-pos)❤️❤️ + +A mobile POS written in _Flutter_, suitable for small cafe/restaurant, fully offline. + +**Tested & printable on **Sunmi V1S** device.** + +![sunmi_v1s](.github/resource/print.jpg) + +**Support:** + +- Android +- Web (unable to print) +- English & Vietnamese (auto detect Locale) + +--- + +## Install & Run + +Get [flutter](https://flutter.dev/) +**IMPORTANT: this project works only with Flutter >= 3.10** + +``` +flutter pub get +flutter run +``` + +### Running inside WSL2 +##### Use **Docker for Destop**'s _Dev Environment_ (note that usbip over Docker Desktop, as of now, hasn't work; you can try debugging over ADB tcpip) +Or +##### Run Docker containers inside of WSL2 +1. Build image and run container: `docker-compose -f .\compose-dev.yaml up -d --build` +2. SSH inside: `docker exec -it flutter_dev bash` +3. Accept licences: `flutter doctor --android-licenses` +4. Clean: `flutter clean` +5. Run: + - Web: `flutter run -d web-server` (Visual studio code should forward the port automatically if you use _Remote window_) + - USB-connected Android device: follow the instruction [here](https://learn.microsoft.com/en-us/windows/wsl/connect-usb) to connect your phone into WSL2, remember to kill the running ADB server on your Windows host machine first + +## Testing +`flutter test` + +## TODO +- [ ] Remote printing? (via Bluetooth) diff --git a/android/build.gradle b/android/build.gradle index e50c3a0..f7eb7f6 100644 --- a/android/build.gradle +++ b/android/build.gradle @@ -26,6 +26,6 @@ subprojects { project.evaluationDependsOn(':app') } -task clean(type: Delete) { +tasks.register("clean", Delete) { delete rootProject.buildDir } diff --git a/compose-dev.yaml b/compose-dev.yaml new file mode 100644 index 0000000..d90d29f --- /dev/null +++ b/compose-dev.yaml @@ -0,0 +1,16 @@ +services: + flutter: + container_name: flutter_dev + privileged: true + entrypoint: + - sleep + - infinity + build: . + init: true + volumes: + - type: bind + source: /var/run/docker.sock + target: /var/run/docker.sock + - ./:/usr/vscode/pos_app + - ./:/com.docker.devenvironments.code + working_dir: /usr/vscode/pos_app