Skip to content

Commit

Permalink
Minor UI changes
Browse files Browse the repository at this point in the history
  • Loading branch information
dwarakavikraman committed Jan 11, 2022
1 parent fcb291b commit ea341d4
Show file tree
Hide file tree
Showing 4 changed files with 67 additions and 46 deletions.
1 change: 1 addition & 0 deletions android/app/src/main/AndroidManifest.xml
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="com.example.tic_tac_toe">
<uses-permission android:name="android.permission.VIBRATE" />
<application
android:label="Tic Tac Toe"
android:name="${applicationName}"
Expand Down
98 changes: 54 additions & 44 deletions lib/pages/choose.dart
Original file line number Diff line number Diff line change
Expand Up @@ -41,57 +41,67 @@ class _ChooserPageState extends State<ChooserPage> {
mainAxisSize: MainAxisSize.max,
mainAxisAlignment: MainAxisAlignment.spaceEvenly,
children: [
const Text(
'Choose your side',
style: TextStyle(fontSize: 20),
),
GridView.count(
crossAxisCount: 2,
shrinkWrap: true,
physics: const NeverScrollableScrollPhysics(),
crossAxisSpacing: 16,
mainAxisSpacing: 42,
padding: const EdgeInsets.all(10),
Column(
children: [
SelectableCard(
child: const X(),
onTap: () => setSide(true),
isSelected: isXSelected,
const Text(
'Choose your side',
style: TextStyle(fontSize: 20),
),
SelectableCard(
child: const O(),
onTap: () => setSide(false),
isSelected: !isXSelected,
const SizedBox(height: 16),
GridView.count(
crossAxisCount: 2,
shrinkWrap: true,
physics: const NeverScrollableScrollPhysics(),
crossAxisSpacing: 16,
mainAxisSpacing: 42,
padding: const EdgeInsets.all(10),
children: [
SelectableCard(
child: const X(),
onTap: () => setSide(true),
isSelected: isXSelected,
),
SelectableCard(
child: const O(),
onTap: () => setSide(false),
isSelected: !isXSelected,
),
],
),
],
),
const Text(
'Choose the difficulty',
style: TextStyle(fontSize: 20),
),
GridView.count(
crossAxisCount: 2,
shrinkWrap: true,
physics: const NeverScrollableScrollPhysics(),
crossAxisSpacing: 16,
mainAxisSpacing: 42,
padding: const EdgeInsets.all(10),
Column(
children: [
SelectableCard(
child: const Text(
'Easy',
style: TextStyle(fontSize: 20),
),
onTap: () => setMode(true),
isSelected: isEasyMode,
const Text(
'Choose the difficulty',
style: TextStyle(fontSize: 20),
),
SelectableCard(
child: const Text(
'Hard',
style: TextStyle(fontSize: 20),
),
onTap: () => setMode(false),
isSelected: !isEasyMode,
const SizedBox(height: 16),
GridView.count(
crossAxisCount: 2,
shrinkWrap: true,
physics: const NeverScrollableScrollPhysics(),
crossAxisSpacing: 16,
mainAxisSpacing: 42,
padding: const EdgeInsets.all(10),
children: [
SelectableCard(
child: const Text(
'Easy',
style: TextStyle(fontSize: 20),
),
onTap: () => setMode(true),
isSelected: isEasyMode,
),
SelectableCard(
child: const Text(
'Hard',
style: TextStyle(fontSize: 20),
),
onTap: () => setMode(false),
isSelected: !isEasyMode,
),
],
),
],
),
Expand Down
14 changes: 12 additions & 2 deletions lib/pages/game.dart
Original file line number Diff line number Diff line change
Expand Up @@ -177,20 +177,30 @@ class _GamePageState extends State<GamePage> {
return isXTurn ? 'O' : 'X';
}

makeMove(int index) {
vibrateLongDuration() async {
HapticFeedback.vibrate();
await Future.delayed(const Duration(milliseconds: 100));
HapticFeedback.vibrate();
await Future.delayed(const Duration(milliseconds: 100));
HapticFeedback.vibrate();
}

makeMove(int index) async {
setState(() {
board[index] = isXTurn ? 'X' : 'O';
isXTurn = !isXTurn;
totalMoves++;
});
HapticFeedback.vibrate();
HapticFeedback.selectionClick();

if (isGameOver()) {
vibrateLongDuration();
setState(() {
gameState = GameState.done;
});
} else if ((isXTurn && widget.playerX == PlayerType.computer) ||
(!isXTurn && widget.playerO == PlayerType.computer)) {
await Future.delayed(Duration(milliseconds: 250));
computerMove();
}
}
Expand Down
Binary file modified screenshots/2.jpg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.

0 comments on commit ea341d4

Please sign in to comment.