Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat(documentation): add documentation in the app #29

Merged
merged 1 commit into from
Feb 18, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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/IntelliJ 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(
Expand Down
10 changes: 10 additions & 0 deletions lib/models/puzzle.dart
Original file line number Diff line number Diff line change
@@ -1,5 +1,8 @@
import 'package:puzzle/models/models.dart';

/// Class Puzzle
/// Complexity management
/// List Tile management
class Puzzle {
final int complexity;
final List<Tile> data;
Expand All @@ -9,6 +12,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 @@ -64,13 +68,15 @@ class Puzzle {
);
}

/// Check if move left is 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 @@ -84,6 +90,7 @@ class Puzzle {
return move(data[valueIndex].value);
}

/// Check if move right is possible
bool canSwapRight() {
final int emptyIndex =
data.indexOf(data.firstWhere((tile) => tile.value == 0));
Expand All @@ -105,6 +112,7 @@ class Puzzle {
return move(data[valueIndex].value);
}

/// Check if move in up is possible
bool canSwapUp() {
final int emptyIndex =
data.indexOf(data.firstWhere((tile) => tile.value == 0));
Expand All @@ -128,6 +136,7 @@ class Puzzle {
return move(data[valueIndex].value);
}

/// Check if move in down is possible
bool canSwapDown() {
final int emptyIndex =
data.indexOf(data.firstWhere((tile) => tile.value == 0));
Expand All @@ -151,6 +160,7 @@ class Puzzle {
return move(data[valueIndex].value);
}

/// Check if move is possible
bool canSwap(int value) {
final int emptyIndex = values.indexOf(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/puzzle_page.dart
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,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 @@ -113,16 +114,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 @@ -137,6 +141,7 @@ class _PuzzlePageState extends State<PuzzlePage> {
}
}

/// Build the portrait mode
Widget _buildPortrait(BuildContext context, PuzzleState state) {
return Scaffold(
bottomNavigationBar: Padding(
Expand Down Expand Up @@ -203,6 +208,7 @@ class _PuzzlePageState extends State<PuzzlePage> {
);
}

/// Build the landscape mode
Widget _buildLandscape(BuildContext context, PuzzleState state) {
return Scaffold(
body: Column(
Expand Down