Skip to content

Commit

Permalink
Add label text
Browse files Browse the repository at this point in the history
  • Loading branch information
praslnx8 committed Jan 3, 2024
1 parent c577380 commit d170752
Show file tree
Hide file tree
Showing 5 changed files with 22 additions and 26 deletions.
6 changes: 1 addition & 5 deletions lib/presentation/create_investment_presenter.dart
Original file line number Diff line number Diff line change
Expand Up @@ -101,15 +101,11 @@ class CreateInvestmentViewState {
SingleEvent<void>? onInvestmentCreated;
List<BasketDO> baskets = List.empty(growable: false);

bool isValid({int? investmentId}) {
if (investmentId != null) {
return name.isNotEmpty && basketId != null;
} else {
bool isValid() {
return name.isNotEmpty &&
value > 0 &&
isValidDate(valueUpdatedAt) &&
basketId != null;
}
}

DateTime _getValueUpdatedAt() {
Expand Down
6 changes: 4 additions & 2 deletions lib/ui/pages/goals_page.dart
Original file line number Diff line number Diff line change
Expand Up @@ -67,9 +67,11 @@ class _GoalsPage extends PageState<GoalsViewState, GoalsPage, GoalsPresenter> {
Text(goal.name,
style: Theme.of(context).textTheme.titleMedium),
const Text(' | '),
Text(_getImportance(goal.importance)),
Text('${_getImportance(goal.importance)} Importance',
style: Theme.of(context).textTheme.labelSmall),
const Text(' | '),
Text('(${_getYearsLeft(goal.getYearsLeft())})'),
Text('(${_getYearsLeft(goal.getYearsLeft())})',
style: Theme.of(context).textTheme.labelSmall),
PopupMenuButton<int>(
onSelected: (value) {
if (value == 1) {
Expand Down
4 changes: 2 additions & 2 deletions lib/ui/pages/investments_page.dart
Original file line number Diff line number Diff line change
Expand Up @@ -71,10 +71,10 @@ class _InvestmentsPage extends PageState<InvestmentsViewState, InvestmentsPage,
children: [
Text(investment.name,
style: Theme.of(context).textTheme.titleMedium),
const Text(' | '),
Text('(${investment.basketName})'),
const Text(' | '),
Text(_getRiskLevel(investment.riskLevel)),
Text('${_getRiskLevel(investment.riskLevel)} Risk',
style: Theme.of(context).textTheme.labelSmall),
PopupMenuButton<int>(
onSelected: (value) {
if (value == 1) {
Expand Down
15 changes: 7 additions & 8 deletions lib/ui/widgets/create_goal_dialog.dart
Original file line number Diff line number Diff line change
Expand Up @@ -99,7 +99,7 @@ class _CreateGoalPage extends PageState<CreateGoalViewState, _CreateGoalDialog,
decoration: const InputDecoration(
labelText: 'Name', border: OutlineInputBorder()),
),
const SizedBox(height: AppDimen.minPadding),
const SizedBox(height: AppDimen.defaultPadding),
TextFormField(
textInputAction: TextInputAction.next,
controller: _amountController,
Expand All @@ -108,7 +108,7 @@ class _CreateGoalPage extends PageState<CreateGoalViewState, _CreateGoalDialog,
decoration: const InputDecoration(
labelText: 'Amount', border: OutlineInputBorder()),
),
const SizedBox(height: AppDimen.minPadding),
const SizedBox(height: AppDimen.defaultPadding),
TextFormField(
textInputAction: TextInputAction.next,
controller: _currentDateController,
Expand All @@ -118,7 +118,7 @@ class _CreateGoalPage extends PageState<CreateGoalViewState, _CreateGoalDialog,
decoration: const InputDecoration(
labelText: 'Date (DD-MM-YYYY)', border: OutlineInputBorder()),
),
const SizedBox(height: AppDimen.minPadding),
const SizedBox(height: AppDimen.defaultPadding),
TextFormField(
textInputAction: TextInputAction.next,
controller: _targetDateController,
Expand All @@ -129,7 +129,7 @@ class _CreateGoalPage extends PageState<CreateGoalViewState, _CreateGoalDialog,
labelText: 'Target Date (DD-MM-YYYY)',
border: OutlineInputBorder()),
),
const SizedBox(height: AppDimen.minPadding),
const SizedBox(height: AppDimen.defaultPadding),
TextFormField(
textInputAction: TextInputAction.next,
keyboardType: TextInputType.number,
Expand All @@ -139,7 +139,7 @@ class _CreateGoalPage extends PageState<CreateGoalViewState, _CreateGoalDialog,
hintText: 'Inflation (0 - 100)',
border: OutlineInputBorder()),
),
const SizedBox(height: AppDimen.minPadding),
const SizedBox(height: AppDimen.defaultPadding),
Row(
mainAxisAlignment: MainAxisAlignment.spaceBetween,
children: [
Expand All @@ -154,11 +154,10 @@ class _CreateGoalPage extends PageState<CreateGoalViewState, _CreateGoalDialog,
),
],
),
const SizedBox(height: AppDimen.minPadding),
const SizedBox(height: AppDimen.defaultPadding),
DropdownButtonFormField<GoalImportance>(
decoration: const InputDecoration(
border: OutlineInputBorder(),
),
border: OutlineInputBorder(), labelText: 'Importance'),
hint: const Text('Importance'),
value: snapshot.importance,
onChanged: (value) {
Expand Down
17 changes: 8 additions & 9 deletions lib/ui/widgets/create_investment_dialog.dart
Original file line number Diff line number Diff line change
Expand Up @@ -83,7 +83,7 @@ class _CreateInvestmentPage extends PageState<CreateInvestmentViewState,
decoration: const InputDecoration(
labelText: 'Name', border: OutlineInputBorder()),
),
const SizedBox(height: AppDimen.minPadding),
const SizedBox(height: AppDimen.defaultPadding),
TextFormField(
textInputAction: TextInputAction.next,
controller: _valueController,
Expand All @@ -92,7 +92,7 @@ class _CreateInvestmentPage extends PageState<CreateInvestmentViewState,
decoration: const InputDecoration(
labelText: 'Value', border: OutlineInputBorder()),
),
const SizedBox(height: AppDimen.minPadding),
const SizedBox(height: AppDimen.defaultPadding),
TextFormField(
textInputAction: TextInputAction.next,
controller: _valueUpdatedDateController,
Expand All @@ -102,9 +102,10 @@ class _CreateInvestmentPage extends PageState<CreateInvestmentViewState,
decoration: const InputDecoration(
labelText: 'Date (DD-MM-YYYY)', border: OutlineInputBorder()),
),
const SizedBox(height: AppDimen.minPadding),
const SizedBox(height: AppDimen.defaultPadding),
DropdownButtonFormField<int>(
decoration: const InputDecoration(border: OutlineInputBorder()),
decoration: const InputDecoration(
border: OutlineInputBorder(), labelText: 'Basket'),
hint: const Text('Basket'),
value: snapshot.basketId,
onChanged: (value) {
Expand All @@ -118,11 +119,10 @@ class _CreateInvestmentPage extends PageState<CreateInvestmentViewState,
child: Text(e.name),
))
.toList()),
const SizedBox(height: AppDimen.minPadding),
const SizedBox(height: AppDimen.defaultPadding),
DropdownButtonFormField<RiskLevel>(
decoration: const InputDecoration(
border: OutlineInputBorder(),
),
border: OutlineInputBorder(), labelText: 'Risk Level'),
hint: const Text('Risk Level'),
value: snapshot.riskLevel,
onChanged: (value) {
Expand Down Expand Up @@ -153,8 +153,7 @@ class _CreateInvestmentPage extends PageState<CreateInvestmentViewState,
Navigator.pop(context);
}),
ElevatedButton(
onPressed: snapshot.isValid(
investmentId: widget.investmentToUpdate?.id)
onPressed: snapshot.isValid()
? () {
presenter.createInvestment(
investmentIdToUpdate: widget.investmentToUpdate?.id);
Expand Down

0 comments on commit d170752

Please sign in to comment.