Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
M
Mobile Computing Group 5
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Requirements
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Locked files
Build
Pipelines
Jobs
Pipeline schedules
Test cases
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
Code review analytics
Issue analytics
Insights
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
This is an archived project. Repository and other project resources are read-only.
Show more breadcrumbs
Hannes Raschke
Mobile Computing Group 5
Commits
e339715c
Commit
e339715c
authored
1 year ago
by
Celine Schmitt
Browse files
Options
Downloads
Patches
Plain Diff
Icons and Color switch
parent
d3e47e92
No related branches found
No related tags found
No related merge requests found
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
trackeroo/lib/frontend/views/edit_category_view.dart
+102
-12
102 additions, 12 deletions
trackeroo/lib/frontend/views/edit_category_view.dart
with
102 additions
and
12 deletions
trackeroo/lib/frontend/views/edit_category_view.dart
+
102
−
12
View file @
e339715c
...
@@ -15,12 +15,24 @@ class EditCategoryPage extends StatefulWidget {
...
@@ -15,12 +15,24 @@ class EditCategoryPage extends StatefulWidget {
class
_EditCategoryPageState
extends
State
<
EditCategoryPage
>
{
class
_EditCategoryPageState
extends
State
<
EditCategoryPage
>
{
TextEditingController
_nameController
=
TextEditingController
();
TextEditingController
_nameController
=
TextEditingController
();
Color
_selectedColor
=
Colors
.
red
;
Color
_selectedColor
=
Colors
.
red
;
IconData
_selectedIcon
=
Icons
.
star
;
@override
@override
void
initState
()
{
void
initState
()
{
super
.
initState
();
super
.
initState
();
_nameController
.
text
=
widget
.
category
.
title
;
_nameController
.
text
=
widget
.
category
.
title
;
_selectedColor
=
Color
(
widget
.
category
.
colorValue
);
_selectedColor
=
Color
(
widget
.
category
.
colorValue
);
_selectedIcon
=
_getValidIconData
(
widget
.
category
.
iconCodePoint
);
}
IconData
_getValidIconData
(
int
codePoint
)
{
if
(
codePoint
==
Icons
.
star
.
codePoint
)
{
return
Icons
.
star
;
}
else
if
(
codePoint
==
Icons
.
favorite
.
codePoint
)
{
return
Icons
.
favorite
;
}
else
{
return
Icons
.
star
;
}
}
}
@override
@override
...
@@ -34,8 +46,8 @@ class _EditCategoryPageState extends State<EditCategoryPage> {
...
@@ -34,8 +46,8 @@ class _EditCategoryPageState extends State<EditCategoryPage> {
Category
updatedCategory
=
Category
(
Category
updatedCategory
=
Category
(
id:
widget
.
category
.
id
,
id:
widget
.
category
.
id
,
title:
newName
,
title:
newName
,
iconCodePoint:
widget
.
category
.
iconC
odePoint
,
iconCodePoint:
_selectedIcon
.
c
odePoint
,
iconFontFamily:
widget
.
category
.
iconFontFamily
,
iconFontFamily:
'MaterialIcons'
,
colorValue:
_selectedColor
.
value
,
colorValue:
_selectedColor
.
value
,
spendings:
widget
.
category
.
spendings
,
spendings:
widget
.
category
.
spendings
,
budget:
widget
.
category
.
budget
,
budget:
widget
.
category
.
budget
,
...
@@ -85,6 +97,27 @@ class _EditCategoryPageState extends State<EditCategoryPage> {
...
@@ -85,6 +97,27 @@ class _EditCategoryPageState extends State<EditCategoryPage> {
);
);
}
}
void
_onIconChanged
(
IconData
?
newIcon
)
{
if
(
newIcon
!=
null
)
{
setState
(()
{
_selectedIcon
=
newIcon
;
});
}
}
Widget
_buildIconContainer
(
IconData
iconData
)
{
return
Container
(
decoration:
BoxDecoration
(
color:
_selectedColor
,
shape:
BoxShape
.
circle
,
),
child:
Icon
(
iconData
,
color:
Colors
.
white
,
),
);
}
@override
@override
Widget
build
(
BuildContext
context
)
{
Widget
build
(
BuildContext
context
)
{
return
Scaffold
(
return
Scaffold
(
...
@@ -108,37 +141,94 @@ class _EditCategoryPageState extends State<EditCategoryPage> {
...
@@ -108,37 +141,94 @@ class _EditCategoryPageState extends State<EditCategoryPage> {
controller:
_nameController
,
controller:
_nameController
,
decoration:
const
InputDecoration
(
decoration:
const
InputDecoration
(
labelText:
'Name'
,
labelText:
'Name'
,
),
),
),
),
const
SizedBox
(
height:
16.0
),
const
SizedBox
(
height:
16.0
),
Row
(
Row
(
children:
[
children:
[
const
Text
(
const
Text
(
'Farbe:'
,
'Farbe'
,
style:
TextStyle
(
fontSize:
16.0
),
style:
TextStyle
(
fontSize:
19.0
,
fontWeight:
FontWeight
.
bold
,
),
),
),
const
SizedBox
(
width:
8
.0
),
const
SizedBox
(
width:
16
.0
),
GestureDetector
(
GestureDetector
(
onTap:
_showColorPicker
,
onTap:
_showColorPicker
,
child:
Container
(
child:
Container
(
width:
3
0
.0
,
width:
3
2
.0
,
height:
3
0
.0
,
height:
3
2
.0
,
decoration:
BoxDecoration
(
decoration:
BoxDecoration
(
color:
_selectedColor
,
color:
_selectedColor
,
border:
Border
.
all
(
color:
Colors
.
black
)
,
shape:
BoxShape
.
circle
,
),
),
),
),
),
),
],
],
),
),
const
SizedBox
(
height:
16.0
),
const
SizedBox
(
height:
16.0
),
ElevatedButton
(
Row
(
onPressed:
_updateCategoryName
,
children:
[
child:
const
Text
(
'Speichern'
),
const
Text
(
'Icon'
,
style:
TextStyle
(
fontSize:
19.0
,
fontWeight:
FontWeight
.
bold
,
),
),
const
SizedBox
(
width:
16.0
),
Expanded
(
child:
GridView
.
count
(
shrinkWrap:
true
,
crossAxisCount:
6
,
childAspectRatio:
1.0
,
children:
[
Icons
.
star
,
Icons
.
favorite
,
Icons
.
attach_money
,
Icons
.
shopping_cart
,
Icons
.
home
,
Icons
.
work
,
Icons
.
school
,
Icons
.
pets
,
Icons
.
luggage
,
Icons
.
savings
,
Icons
.
liquor
,
Icons
.
celebration
,
]
.
map
((
iconData
)
{
return
GestureDetector
(
onTap:
()
{
_onIconChanged
(
iconData
);
},
child:
Container
(
decoration:
BoxDecoration
(
border:
Border
.
all
(
color:
_selectedIcon
==
iconData
?
Colors
.
blue
:
Colors
.
transparent
,
width:
2.0
,
),
),
child:
_buildIconContainer
(
iconData
),
),
),
);
})
.
toList
(),
),
),
],
),
const
SizedBox
(
height:
16.0
),
ElevatedButton
(
onPressed:
_updateCategoryName
,
child:
const
Text
(
'Speichern'
),
),
],
],
),
),
),
),
);
);
}
}
}
}
\ No newline at end of file
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