Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
ginkgo
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
Service Desk
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
Fred
ginkgo
Commits
10ba8b5e
Commit
10ba8b5e
authored
1 year ago
by
vjrj
Browse files
Options
Downloads
Patches
Plain Diff
Improve calculs in payments
parent
10bb9975
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
lib/ui/ui_helpers.dart
+37
-2
37 additions, 2 deletions
lib/ui/ui_helpers.dart
with
37 additions
and
2 deletions
lib/ui/ui_helpers.dart
+
37
−
2
View file @
10ba8b5e
...
...
@@ -144,8 +144,9 @@ String formatAmountWithLocale(String locale, double amount) {
String
formatKAmount
(
BuildContext
context
,
double
amount
)
=
>
formatAmount
(
context
,
amount
/
100
);
double
parseToDoubleLocalized
(
String
locale
,
String
double
)
=
>
NumberFormat
.
decimalPattern
(
locale
)
.
parse
(
double
)
.
toDouble
();
double
parseToDoubleLocalized
(
{
required
String
locale
,
required
String
number
})
=
>
NumberFormat
.
decimalPattern
(
locale
)
.
parse
(
number
)
.
toDouble
();
String
localizeNumber
(
BuildContext
context
,
double
amount
)
=
>
NumberFormat
.
decimalPattern
(
context
.
locale
.
toString
())
.
format
(
amount
);
...
...
@@ -241,3 +242,37 @@ ImageIcon get g1nkgoIcon => ImageIcon(
String
get
ginkgoIconLocation
=
>
assets
(
'img/favicon.png'
);
String
capitalize
(
String
s
)
=
>
s
[
0
]
.
toUpperCase
()
+
s
.
substring
(
1
);
double
calculate
({
required
String
textInTerminal
,
required
String
decimalSep
})
{
String
operation
=
textInTerminal
;
double
sum
=
0.0
;
operation
=
operation
.
replaceAll
(
decimalSep
,
'.'
);
// change decimal separator to a dot
final
RegExp
regex
=
RegExp
(
r'[\d.]+'
);
// regular expression to find numbers
final
Iterable
<
Match
>
matches
=
regex
.
allMatches
(
operation
);
// find all numbers in the input
for
(
final
Match
?
match
in
matches
)
{
try
{
if
(
match
!=
null
)
{
final
String
?
g1
=
match
.
group
(
0
);
if
(
g1
!=
null
)
{
sum
+=
double
.
parse
(
g1
);
// add the number to the sum
}
}
}
catch
(
e
)
{
// could not convert the number to a double value, ignore it
}
}
// logger(numberFormat.format(sum)); // print the formatted sum
return
sum
;
}
String
decimalSep
(
BuildContext
context
)
{
return
NumberFormat
.
decimalPattern
(
context
.
locale
.
toString
())
.
symbols
.
DECIMAL_SEP
;
}
Color
selectedPatternLock
(
BuildContext
context
)
=
>
Colors
.
red
;
Color
notSelectedPatternLock
(
BuildContext
context
)
=
>
Colors
.
amber
;
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