Skip to content

Commit

Permalink
feat(documentation): add documentation in the app
Browse files Browse the repository at this point in the history
  • Loading branch information
MayuriXx committed Feb 18, 2022
1 parent a72f479 commit fa9c824
Show file tree
Hide file tree
Showing 8 changed files with 70 additions and 21 deletions.
68 changes: 47 additions & 21 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,36 +1,62 @@
# Xpeho FlutterPuzzleHack

This project contains the FlutterPuzzleHack Xpeho participation sources
![Photo Booth Header][logo]

## Getting Started With Flutter
A slide puzzle built for [Flutter Challenge](https://flutterhack.devpost.com/).

This project is a starting point for a Flutter application.
*Built by [XPEHO][xpeho_link].*

A few resources to get you started if this is your first Flutter project:

- [Lab: Write your first Flutter app](https://flutter.dev/docs/get-started/codelab)
- [Cookbook: Useful Flutter samples](https://flutter.dev/docs/cookbook)
---

For help getting started with Flutter, view our
[online documentation](https://flutter.dev/docs), which offers tutorials,
samples, guidance on mobile development, and a full API reference.
## Getting Started 🚀

## macOS arm64 Build (M1 chip)
To run the project either use the launch configuration in VSCode/Android Studio or use the following command:

If you use a MacOS machine, you can build the app for arm64 using the following command:
```sh
$ flutter run -d chrome
```

---


## Working with Translations 🌐

This project relies on [flutter_localizations][flutter_localizations_link] and follows the [official internationalization guide for Flutter][internationalization_link].

### Adding Strings

```bash
$ sudo arch -x86_64 gem install ffi
$ cd macos # or ios
$ arch -x86_64 pod install
$ cd ..
$ flutter build macos --debug # or flutter run -d macos
To add a new localizable string, open the `app_en.arb` file at `lib/l10n/arb/app_en.arb`.

```arb
{
"team_name": "Xpeho mobile",
"@team_name": {
"description": "Team name"
}
}
```

This commands will build the macOS app for x86_64 architecture and will run the app using Rosetta.
---

## XPEHO FlutterPuzzleHack Cross Platform ⌚️💻📱

Available platforms :

- [Web][pwa_link]
- IOS
- Android
- MacOS
- Windows

Coming soon Linux and ... WatchOS


## Windows Build
---

In order to build this app for Windows you must previously install Visual Studio 2022.

More details [here](https://docs.flutter.dev/desktop#additional-windows-requirements)
[logo]: assets/images/header_readme.png
[xpeho_link]: https://xpeho.fr/
[flutter_localizations_link]: https://api.flutter.dev/flutter/flutter_localizations/flutter_localizations-library.html
[internationalization_link]: https://flutter.dev/docs/development/accessibility-and-localization/internationalization
[pwa_link]: https://xpeho-flutter-puzzle-hack.web.app/
Binary file added assets/images/header_readme.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
1 change: 1 addition & 0 deletions lib/bloc/puzzle_state.dart
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ import 'package:puzzle/models/models.dart';

part 'puzzle_state.freezed.dart';

///State management for the puzzle
@freezed
class PuzzleState with _$PuzzleState {
factory PuzzleState(Puzzle puzzle, {ui.Image? image}) = _PuzzleState;
Expand Down
7 changes: 7 additions & 0 deletions lib/models/puzzle.dart
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,9 @@ import 'dart:math';

import 'package:puzzle/models/models.dart';

/// Class Puzzle
/// Complexity management
/// List Tile management
class Puzzle {
final int complexity;
final List<Tile> data;
Expand All @@ -12,6 +15,7 @@ class Puzzle {
required this.data,
});

/// Generate value for the puzzle
factory Puzzle.generate(int complexity) {
final data = List<Tile>.generate(complexity * complexity, (index) {
var value = index + 1;
Expand Down Expand Up @@ -67,13 +71,15 @@ class Puzzle {
);
}

/// Move left if possible
bool canSwapLeft() {
final int emptyIndex =
data.indexOf(data.firstWhere((tile) => tile.value == 0));

return (emptyIndex == 0 || (emptyIndex + 1) % complexity != 0);
}

/// try to swap empty tile and the one on the right
Puzzle trySwapLeft() {
final int emptyIndex =
data.indexOf(data.firstWhere((tile) => tile.value == 0));
Expand All @@ -87,6 +93,7 @@ class Puzzle {
return move(data[valueIndex].value);
}

/// Move right if possible
bool canSwapRight() {
final int emptyIndex =
data.indexOf(data.firstWhere((tile) => tile.value == 0));
Expand Down
3 changes: 3 additions & 0 deletions lib/models/tile.dart
Original file line number Diff line number Diff line change
@@ -1,3 +1,6 @@
/// Class Tile
/// Differents position X & Y
/// The value for different tile
class Tile {
int targetX;
int targetY;
Expand Down
4 changes: 4 additions & 0 deletions lib/services/audio_service.dart
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,10 @@ import 'package:flutter/foundation.dart';
import 'package:puzzle/services/shared.dart';
import 'package:volume_controller/volume_controller.dart';

/// Class AudioService for audio player in the app
/// Cache management
/// Volume management
/// Audio player management
class AudioService {
final AudioPlayer _audioPlayer = AudioPlayer();
final AudioCache _audioCache = AudioCache();
Expand Down
2 changes: 2 additions & 0 deletions lib/services/shared.dart
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,8 @@ import 'dart:io';

import 'package:flutter/foundation.dart';

// This file is for method in general
/// Method for detection if we are in mobile or web
bool isMobile() {
if (kIsWeb) {
return false;
Expand Down
6 changes: 6 additions & 0 deletions lib/view/puzzle_page.dart
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,7 @@ class _PuzzlePageState extends State<PuzzlePage> {
void initState() {
super.initState();
_puzzleFocusNode = FocusNode();
//Shake animations : start shuffle function
detector = ShakeDetector.autoStart(onPhoneShake: () {
_shuffle(context);
});
Expand Down Expand Up @@ -123,16 +124,19 @@ class _PuzzlePageState extends State<PuzzlePage> {
_puzzleFocusNode.requestFocus();
}

/// Up complexity of puzzle : Number of tile
void _increaseComplexity(BuildContext context) {
context.read<PuzzleCubit>().increaseComplexity();
_puzzleFocusNode.requestFocus();
}

/// Decrease complexity of puzzle : Number of tile
void _decreaseComplexity(BuildContext context) {
context.read<PuzzleCubit>().decreaseComplexity();
_puzzleFocusNode.requestFocus();
}

/// Load picture for the puzzle
Future<void> _pickImage() async {
FilePickerResult? result = await FilePicker.platform.pickFiles();

Expand All @@ -147,6 +151,7 @@ class _PuzzlePageState extends State<PuzzlePage> {
}
}

/// Different phone mode
Widget _buildPortrait(BuildContext context, PuzzleState state) {
return Padding(
padding: const EdgeInsets.all(16.0),
Expand Down Expand Up @@ -204,6 +209,7 @@ class _PuzzlePageState extends State<PuzzlePage> {
);
}

/// Different phone mode
Widget _buildLandscape(BuildContext context, PuzzleState state) {
return Padding(
padding: const EdgeInsets.all(16.0),
Expand Down

0 comments on commit fa9c824

Please sign in to comment.