Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
org.benoitharrault.puzzlegame
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Package registry
Model registry
Operate
Environments
Terraform modules
Monitor
Incidents
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
android
org.benoitharrault.puzzlegame
Commits
beb3dd56
Commit
beb3dd56
authored
3 years ago
by
Benoît Harrault
Browse files
Options
Downloads
Patches
Plain Diff
Add tile entity
parent
79e2027a
No related branches found
No related tags found
1 merge request
!5
Resolve "Upgrade tiles to clean object"
Pipeline
#1227
passed
3 years ago
Stage: update
Stage: build-debug
Changes
3
Pipelines
1
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
android/gradle.properties
+2
-2
2 additions, 2 deletions
android/gradle.properties
lib/entities/tile.dart
+30
-0
30 additions, 0 deletions
lib/entities/tile.dart
lib/screens/home.dart
+24
-37
24 additions, 37 deletions
lib/screens/home.dart
with
56 additions
and
39 deletions
android/gradle.properties
+
2
−
2
View file @
beb3dd56
org.gradle.jvmargs
=
-Xmx1536M
android.useAndroidX
=
true
android.enableJetifier
=
true
app.versionName
=
0.0.
4
app.versionCode
=
4
app.versionName
=
0.0.
5
app.versionCode
=
5
This diff is collapsed.
Click to expand it.
lib/entities/tile.dart
0 → 100644
+
30
−
0
View file @
beb3dd56
import
'package:flutter/material.dart'
;
class
Tile
{
final
Image
image
;
final
double
size
;
final
int
currentCol
;
final
int
currentRow
;
final
int
originalCol
;
final
int
originalRow
;
Tile
(
@required
this
.
image
,
@required
this
.
size
,
@required
this
.
currentCol
,
@required
this
.
currentRow
,
@required
this
.
originalCol
,
@required
this
.
originalRow
,
);
Container
widget
()
{
return
Container
(
child:
Image
(
image:
this
.
image
.
image
,
width:
this
.
size
,
height:
this
.
size
,
fit:
BoxFit
.
fill
)
);
}
}
This diff is collapsed.
Click to expand it.
lib/screens/home.dart
+
24
−
37
View file @
beb3dd56
...
...
@@ -5,14 +5,15 @@ import 'package:flutter/services.dart' show rootBundle;
import
'package:image/image.dart'
as
imglib
;
import
'package:provider/provider.dart'
;
import
'../entities/tile.dart'
;
import
'../provider/data.dart'
;
import
'../utils/get_images_list.dart'
;
class
Home
extends
StatelessWidget
{
static
const
String
id
=
'home'
;
int
_linesCount
=
3
;
int
_columnsCount
=
3
;
int
_linesCount
=
4
;
int
_columnsCount
=
4
;
double
_selectorImageSize
=
200
;
double
_tipImageSize
=
100
;
...
...
@@ -83,7 +84,7 @@ class Home extends StatelessWidget {
);
}
Future
<
List
<
Imag
e
>>
splitImageInTiles
(
Data
myProvider
)
async
{
Future
<
List
<
Til
e
>>
splitImageInTiles
(
Data
myProvider
)
async
{
String
imageAsset
=
getImageAssetName
(
myProvider
.
image
);
Uint8List
imageData
=
(
await
rootBundle
.
load
(
imageAsset
))
.
buffer
...
...
@@ -94,35 +95,31 @@ class Home extends StatelessWidget {
int
width
=
(
image
.
width
/
_linesCount
)
.
round
();
int
height
=
(
image
.
height
/
_columnsCount
)
.
round
();
List
<
imglib
.
Image
>
parts
=
List
<
imglib
.
Imag
e
>();
List
<
Tile
>
tiles
=
List
<
Til
e
>();
for
(
int
i
=
0
;
i
<
_linesCount
;
i
++
)
{
for
(
int
j
=
0
;
j
<
_columnsCount
;
j
++
)
{
parts
.
add
(
imglib
.
copyCrop
(
image
,
x
,
y
,
width
,
height
));
tiles
.
add
(
Tile
(
Image
.
memory
(
imglib
.
encodeJpg
(
imglib
.
copyCrop
(
image
,
x
,
y
,
width
,
height
)
)
),
_tileImageSize
,
j
,
i
,
j
,
i
,
)
);
x
+=
width
;
}
x
=
0
;
y
+=
height
;
}
List
<
Image
>
tiles
=
List
<
Image
>();
for
(
var
img
in
parts
)
{
tiles
.
add
(
Image
.
memory
(
imglib
.
encodeJpg
(
img
)));
}
return
tiles
;
}
Container
_buildImageTileItem
(
Image
tile
)
{
return
Container
(
child:
Image
(
image:
tile
.
image
,
width:
_tileImageSize
,
height:
_tileImageSize
,
fit:
BoxFit
.
fill
)
);
}
Container
_buildTilesetWidget
(
Data
myProvider
)
{
List
tiles
=
myProvider
.
tiles
;
...
...
@@ -139,22 +136,12 @@ class Home extends StatelessWidget {
width:
2
,
),
children:
[
TableRow
(
children:
[
Column
(
children:
[
_buildImageTileItem
(
tiles
[
tileIndex
++
])]),
Column
(
children:
[
_buildImageTileItem
(
tiles
[
tileIndex
++
])]),
Column
(
children:
[
_buildImageTileItem
(
tiles
[
tileIndex
++
])]),
]),
TableRow
(
children:
[
Column
(
children:
[
_buildImageTileItem
(
tiles
[
tileIndex
++
])]),
Column
(
children:
[
_buildImageTileItem
(
tiles
[
tileIndex
++
])]),
Column
(
children:
[
_buildImageTileItem
(
tiles
[
tileIndex
++
])]),
]),
TableRow
(
children:
[
Column
(
children:
[
_buildImageTileItem
(
tiles
[
tileIndex
++
])]),
Column
(
children:
[
_buildImageTileItem
(
tiles
[
tileIndex
++
])]),
Column
(
children:
[
_buildImageTileItem
(
tiles
[
tileIndex
++
])]),
]),
],
for
(
var
row
=
0
;
row
<
_linesCount
;
row
++
)
TableRow
(
children:
[
for
(
var
col
=
0
;
col
<
_columnsCount
;
col
++
)
Column
(
children:
[
tiles
[
tileIndex
++
]
.
widget
()]),
]),
]
);
return
Container
(
...
...
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment