Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
A
Ambient
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
Container 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
GitLab community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
Daniel Furaev
Ambient
Commits
82667de7
Commit
82667de7
authored
2 years ago
by
Erik Hinkelmanns
Browse files
Options
Downloads
Plain Diff
Merge remote-tracking branch 'origin/main' into mergeHELL
# Conflicts: # lib/main.dart
parents
646c30b9
6afc269a
No related branches found
No related tags found
No related merge requests found
Changes
2
Show whitespace changes
Inline
Side-by-side
Showing
2 changed files
lib/main.dart
+1
-1
1 addition, 1 deletion
lib/main.dart
lib/moodpage.dart
+78
-8
78 additions, 8 deletions
lib/moodpage.dart
with
79 additions
and
9 deletions
lib/main.dart
+
1
−
1
View file @
82667de7
...
...
@@ -74,7 +74,7 @@ class _HUDState extends State<HUD> {
},
children:
const
[
HomePage
(),
empty
Mood
p
age
(),
State
Mood
P
age
(),
StateSearcgPage
(),
],
),
...
...
This diff is collapsed.
Click to expand it.
lib/moodpage.dart
+
78
−
8
View file @
82667de7
import
'package:ambient/widgets/navbars.dart'
;
import
'dart:io'
;
import
'package:vector_math/vector_math.dart'
;
import
'package:image_picker/image_picker.dart'
;
import
'package:flutter/material.dart'
;
import
'package:palette_generator/palette_generator.dart'
;
...
...
@@ -11,10 +11,26 @@ class StateMoodPage extends StatefulWidget {
State
<
StateMoodPage
>
createState
()
=
>
MoodPage
();
}
enum
Moods
{
none
,
happy
,
sad
}
extension
MoodsExtention
on
Moods
{
Color
get
color
{
switch
(
this
)
{
case
Moods
.
none
:
return
Color
.
fromARGB
(
255
,
75
,
75
,
75
);
case
Moods
.
happy
:
return
Color
.
fromARGB
(
255
,
237
,
219
,
18
);
case
Moods
.
sad
:
return
Color
.
fromARGB
(
255
,
64
,
71
,
167
);
}
}
}
class
MoodPage
extends
State
<
StateMoodPage
>
{
late
File
_image
;
final
ImagePicker
_picker
=
ImagePicker
();
late
PaletteGenerator
paletteGenerator
;
Moods
?
currentMood
=
Moods
.
happy
;
String
imagePath
=
""
;
_getFromGallery
()
async
{
...
...
@@ -34,6 +50,54 @@ class MoodPage extends State<StateMoodPage> {
}
}
_getColorDistance
(
Color
c1
,
Color
c2
)
{
double
distance
=
0
;
Vector3
v1
=
Vector3
(
c1
.
red
.
toDouble
(),
c1
.
green
.
toDouble
(),
c1
.
blue
.
toDouble
());
Vector3
v2
=
Vector3
(
c2
.
red
.
toDouble
(),
c2
.
green
.
toDouble
(),
c2
.
blue
.
toDouble
());
distance
=
v1
.
distanceTo
(
v2
)
.
toInt
()
.
toDouble
();
return
distance
;
}
_determineMoodToMatch
(
Color
col
)
{
double
distance
=
1000.0
;
Moods
newMood
=
Moods
.
none
;
for
(
var
value
in
Moods
.
values
)
{
if
(
_getColorDistance
(
col
,
value
.
color
)
<
distance
&&
value
!=
Moods
.
none
)
{
distance
=
_getColorDistance
(
col
,
value
.
color
);
newMood
=
value
;
}
}
return
newMood
;
}
_getMoodList
()
{
return
Column
(
children:
<
Widget
>[
RadioListTile
<
Moods
>(
title:
const
Text
(
'Happy'
),
value:
Moods
.
happy
,
groupValue:
currentMood
,
onChanged:
(
Moods
?
value
)
{
setState
(()
{
currentMood
=
value
;
});
},
),
RadioListTile
<
Moods
>(
title:
const
Text
(
'Sad'
),
value:
Moods
.
sad
,
groupValue:
currentMood
,
onChanged:
(
Moods
?
value
)
{
setState
(()
{
currentMood
=
value
;
});
},
),
]);
}
_getContainerTodisplay
()
{
BoxDecoration
deco
=
new
BoxDecoration
();
var
image
;
...
...
@@ -46,8 +110,8 @@ class MoodPage extends State<StateMoodPage> {
),
);
}
else
{
deco
=
new
BoxDecoration
(
color:
Color
s
.
purple
,
deco
=
const
BoxDecoration
(
color:
Color
.
fromARGB
(
255
,
64
,
71
,
167
)
,
);
}
return
Container
(
...
...
@@ -83,11 +147,14 @@ class MoodPage extends State<StateMoodPage> {
(
BuildContext
context
,
AsyncSnapshot
<
PaletteGenerator
>
snapshot
)
{
switch
(
snapshot
.
connectionState
)
{
case
ConnectionState
.
waiting
:
return
Center
(
child:
CircularProgressIndicator
());
return
const
Center
(
child:
CircularProgressIndicator
());
default
:
if
(
snapshot
.
hasError
)
{
return
PaletteSquare
(
color:
Color
.
fromARGB
(
255
,
236
,
177
,
173
));
return
const
PaletteSquare
(
color:
Color
.
fromARGB
(
255
,
173
,
188
,
236
));
}
else
{
currentMood
=
_determineMoodToMatch
(
snapshot
.
data
!.
dominantColor
!.
color
);
return
Row
(
children:
<
Widget
>[
PaletteSquare
(
color:
snapshot
.
data
!.
mutedColor
!.
color
),
PaletteSquare
(
color:
snapshot
.
data
!.
vibrantColor
!.
color
),
...
...
@@ -103,16 +170,19 @@ class MoodPage extends State<StateMoodPage> {
@override
Widget
build
(
BuildContext
context
)
{
return
Scaffold
(
appBar:
AppBar
(
title:
const
Text
(
"MoodPage"
),
),
body:
Center
(
child:
Column
(
//mainAxisAlignment: MainAxisAlignment.center,
children:
<
Widget
>[
_getContainerTodisplay
(),
_getCollorIndicator
(),
_getMoodList
(),
TextButton
(
style:
ButtonStyle
(
foregroundColor:
MaterialStateProperty
.
all
(
Theme
.
of
(
context
)
.
hintColor
),
foregroundColor:
MaterialStateProperty
.
all
(
Theme
.
of
(
context
)
.
primaryColorLight
),
backgroundColor:
MaterialStateProperty
.
all
(
Theme
.
of
(
context
)
.
backgroundColor
),
),
...
...
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