Skip to content

Commit 20a0ff6

Browse files
author
Ihor Khomiak
committed
refactor code
1 parent 4e9506f commit 20a0ff6

31 files changed

+205
-435
lines changed

app/app.css

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,20 @@
44
font-family: "FontAwesome", fontawesome-webfont;
55
}
66

7+
ActionBar, .action-bar {
8+
background-color: #7ada2f;
9+
color: aliceblue;
10+
}
11+
12+
SegmentedBar {
13+
background-color: #D3D3D3;
14+
}
15+
16+
.main-container {
17+
height: 100%;
18+
width: 100%;
19+
}
20+
721
.tag-item {
822
vertical-align: middle;
923
background-color: #7ada2f;

app/app.module.ts

Lines changed: 10 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -8,15 +8,17 @@ import { AppComponent } from './app.component';
88
import { AppRoutingModule, authProviders } from './app.routing';
99
import { Config } from './common/config';
1010
import { BudgetComponent } from './components/budget/budget.component';
11-
import { BudgetModule } from './components/budget/budget.module';
1211
import { DateRangeComponent } from './components/date-range/date-range.component';
1312
import { ChartComponent } from './components/chart/chart.component';
14-
import { CostModule } from './components/cost/cost.module';
1513
import { CostsComponent } from './components/cost/costs.component';
1614
import { ListComponent } from './components/list/list.component';
1715
import { LoginComponent } from './components/login/login.component';
1816
import { RegisterComponent } from './components/login/register/register.component';
1917
import { TabsComponent } from './components/tabs/tabs.component';
18+
import { BudgetService } from './services/budget.service';
19+
import { CostDetailComponent } from './components/cost/detail/cost-detail.component';
20+
import { CostEditComponent } from './components/cost/edit/cost-edit.component';
21+
import { CostService } from './services/cost.service';
2022

2123
@NgModule({
2224
bootstrap: [
@@ -26,14 +28,14 @@ import { TabsComponent } from './components/tabs/tabs.component';
2628
NativeScriptModule,
2729
AppRoutingModule,
2830
NativeScriptFormsModule,
29-
NativeScriptUIChartModule,
30-
CostModule,
31-
BudgetModule
31+
NativeScriptUIChartModule
3232
],
3333
declarations: [
3434
AppComponent,
3535
TabsComponent,
3636
CostsComponent,
37+
CostDetailComponent,
38+
CostEditComponent,
3739
LoginComponent,
3840
RegisterComponent,
3941
DateRangeComponent,
@@ -43,7 +45,9 @@ import { TabsComponent } from './components/tabs/tabs.component';
4345
],
4446
providers: [
4547
authProviders,
46-
Config
48+
Config,
49+
CostService,
50+
BudgetService
4751
],
4852
schemas: [
4953
NO_ERRORS_SCHEMA

app/common/utils.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,11 @@
11
export class Utils {
22

3-
public static dateToYMD(date) {
3+
public static dateToDMY(date) {
44
let strArray = ['Січ', 'Лют', 'Бер', 'Кві', 'Тра', 'Чер', 'Лип', 'Сеп', 'Вер', 'Жов', 'Лис', 'Гру'];
55
let d = date.getDate();
66
let m = strArray[date.getMonth()];
77
let y = date.getFullYear();
8-
return '' + (d <= 9 ? '0' + d : d) + ' ' + m + ' ' + y;
8+
return (d <= 9 ? '0' + d : d) + ' ' + m + ' ' + y;
99
}
1010

1111
public static formatDateString(dateString: string): string {

app/components/budget/budget.component.css

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,3 @@
1-
ActionBar {
2-
background-color: #7ada2f;
3-
color: aliceblue;
4-
}
5-
61
.container {
72
padding: 30;
83
}
Lines changed: 15 additions & 35 deletions
Original file line numberDiff line numberDiff line change
@@ -1,44 +1,24 @@
1-
<ActionBar title="Бюджет"
2-
class="action-bar">
3-
<ActionItem *ngIf="state == 'read'"
4-
(tap)="onEditButtonTap()"
5-
ios.systemIcon="2"
6-
ios.position="right"
7-
android.position="left">
8-
<Label text="&#xf044;"
9-
class="font-awesome action-item action-icon"></Label>
1+
<ActionBar title="Бюджет" class="action-bar">
2+
<ActionItem *ngIf="state == 'read'" (tap)="onEditButtonTap()" position="left">
3+
<Label text="&#xf044;" class="font-awesome action-item action-icon"></Label>
104
</ActionItem>
11-
<ActionItem *ngIf="state == 'edit'"
12-
ios.position="right"
13-
android.position="right"
14-
(tap)="onSaveButtonTap()">
15-
<Label text="&#xf14a;"
16-
class="font-awesome action-item action-icon"></Label>
5+
<ActionItem *ngIf="state == 'edit'" position="right" (tap)="onSaveButtonTap()">
6+
<Label text="&#xf14a;" class="font-awesome action-item action-icon"></Label>
177
</ActionItem>
18-
<NavigationButton text="Повернутись"
19-
android.systemIcon="ic_menu_back"
20-
(tap)="onBackTap()"
8+
<NavigationButton text="Повернутись" android.systemIcon="ic_menu_back" (tap)="onBackTap()"
219
class="btn-back"></NavigationButton>
2210
</ActionBar>
2311

24-
<StackLayout orientation="vertical"
25-
class="container">
26-
<StackLayout *ngIf="state == 'read'"
27-
orientation="horizontal">
28-
<Label text="Бюджет на місяць - "
29-
class="info-label"></Label>
30-
<Label [text]="budgetService.budget"
31-
class="value-label"></Label>
32-
</StackLayout>
12+
<StackLayout class="container">
13+
<StackLayout *ngIf="state == 'read'" orientation="horizontal">
14+
<Label text="Бюджет на місяць - " class="info-label"></Label>
15+
<Label [text]="budgetService.budget" class="value-label"></Label>
16+
</StackLayout>
3317

34-
<StackLayout *ngIf="state == 'edit'"
35-
orientation="vertical">
36-
<Label text="Бюджет на місяць:"
37-
class="info-edit-label"></Label>
38-
<TextField [text]="budgetService.budget"
39-
keyboardType="number"
40-
#editBudgetTextField></TextField>
41-
</StackLayout>
18+
<StackLayout *ngIf="state == 'edit'">
19+
<Label text="Бюджет на місяць:" class="info-edit-label"></Label>
20+
<TextField #editInput [text]="budgetService.budget" keyboardType="number"></TextField>
21+
</StackLayout>
4222
</StackLayout>
4323

4424

app/components/budget/budget.component.ts

Lines changed: 2 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@ import { BudgetService } from '../../services/budget.service';
1212
})
1313
export class BudgetComponent {
1414

15-
@ViewChild("editBudgetTextField") editBudgetTextField: ElementRef;
15+
@ViewChild("editInput") editInput: ElementRef;
1616
private state: string = 'read';
1717

1818
constructor(
@@ -29,7 +29,7 @@ export class BudgetComponent {
2929
}
3030

3131
onSaveButtonTap() {
32-
let textField = <TextField>this.editBudgetTextField.nativeElement;
32+
let textField = <TextField>this.editInput.nativeElement;
3333
textField.dismissSoftInput();
3434

3535
if (textField.text.trim() === "") {
@@ -41,10 +41,6 @@ export class BudgetComponent {
4141
this.state = 'read';
4242
}
4343

44-
onCancelButtonTap() {
45-
this.state = 'read';
46-
}
47-
4844
onBackTap() {
4945
this.routerExtensions.back();
5046
}

app/components/budget/budget.module.ts

Lines changed: 0 additions & 24 deletions
This file was deleted.
Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +0,0 @@
1-
.main-container {
2-
height: 100%;
3-
width: 100%;
4-
}
Lines changed: 21 additions & 39 deletions
Original file line numberDiff line numberDiff line change
@@ -1,44 +1,26 @@
11
<SegmentedBar [items]="barButtons"
2-
(selectedIndexChange)="onSelectedIndexChange($event)"
3-
backgroundColor="#D3D3D3"></SegmentedBar>
2+
(selectedIndexChange)="onSegmentedBarSelectionChange($event)"></SegmentedBar>
43

5-
<PullToRefresh class="main-container"
6-
(refresh)="pullToRefresh($event)">
4+
<PullToRefresh class="main-container" (refresh)="pullToRefresh($event)">
75
<StackLayout padding="30">
8-
<StackLayout visibility="{{ barButtonsSelectedIndex === 0 ? 'visible' : 'collapsed' }}">
9-
<RadCartesianChart allowAnimation="true" seriesSelectionMode="none">
10-
<CategoricalAxis tkCartesianHorizontalAxis></CategoricalAxis>
11-
<LinearAxis tkCartesianVerticalAxis></LinearAxis>
12-
<BarSeries tkCartesianSeries
13-
showLabels="true"
14-
seriesName="inbound"
15-
[items]="cartesianProvider"
16-
categoryProperty="changesMonth"
17-
valueProperty="quantity"></BarSeries>
18-
<Palette tkCartesianPalette
19-
seriesName="inbound">
20-
<PaletteEntry tkCartesianPaletteEntry
21-
fillColor="#1da125"
22-
strokeColor="Transparent"></PaletteEntry>
23-
</Palette>
24-
</RadCartesianChart>
25-
</StackLayout>
26-
<StackLayout visibility="{{ barButtonsSelectedIndex === 1 ? 'visible' : 'collapsed' }}">
27-
<RadPieChart allowAnimation="true">
28-
<PieSeries tkPieSeries
29-
selectionMode="DataPoint"
30-
expandRadius="0.8"
31-
outerRadiusFactor="0.9"
32-
[items]="pieProvider"
33-
valueProperty="quantity"
34-
legendLabel="type"></PieSeries>
35-
<RadLegendView tkPieLegend
36-
position="Right"
37-
title="Типи Витрат (грн)"
38-
offsetOrigin="TopRight"
39-
width="110"
40-
enableSelection="true"></RadLegendView>
41-
</RadPieChart>
42-
</StackLayout>
6+
<RadCartesianChart visibility="{{ barButtonsSelectedIndex === 0 ? 'visible' : 'collapsed' }}"
7+
allowAnimation="true" seriesSelectionMode="none">
8+
<CategoricalAxis tkCartesianHorizontalAxis></CategoricalAxis>
9+
<LinearAxis tkCartesianVerticalAxis></LinearAxis>
10+
<BarSeries tkCartesianSeries showLabels="true" seriesName="inbound"
11+
[items]="cartesianProvider" categoryProperty="changesMonth" valueProperty="quantity"></BarSeries>
12+
<Palette tkCartesianPalette seriesName="inbound">
13+
<PaletteEntry tkCartesianPaletteEntry fillColor="#1da125" strokeColor="Transparent"></PaletteEntry>
14+
</Palette>
15+
</RadCartesianChart>
16+
17+
<RadPieChart visibility="{{ barButtonsSelectedIndex === 1 ? 'visible' : 'collapsed' }}"
18+
allowAnimation="true">
19+
<PieSeries tkPieSeries selectionMode="DataPoint" expandRadius="0.8"
20+
outerRadiusFactor="0.9" [items]="pieProvider" valueProperty="quantity"
21+
legendLabel="type"></PieSeries>
22+
<RadLegendView tkPieLegend position="Right" title="Типи Витрат (грн)"
23+
offsetOrigin="TopRight" width="110" enableSelection="true"></RadLegendView>
24+
</RadPieChart>
4325
</StackLayout>
4426
</PullToRefresh>

app/components/chart/chart.component.ts

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
1-
import { Component, EventEmitter, Output } from '@angular/core';
1+
import { Component } from '@angular/core';
22
import { ObservableArray } from 'tns-core-modules/data/observable-array/observable-array';
3-
import { SegmentedBar, SegmentedBarItem } from "ui/segmented-bar";
3+
import { SegmentedBar, SegmentedBarItem } from 'ui/segmented-bar';
44

55
import { CostService } from '../../services/cost.service';
66

@@ -62,7 +62,7 @@ export class ChartComponent {
6262
this.cartesianProvider = new ObservableArray(this.objectToArray(costMonths));
6363
}
6464

65-
private onSelectedIndexChange(args) {
65+
private onSegmentedBarSelectionChange(args) {
6666
let segmetedBar = <SegmentedBar>args.object;
6767
this.barButtonsSelectedIndex = segmetedBar.selectedIndex;
6868
if(segmetedBar.selectedIndex === 0) {

0 commit comments

Comments
 (0)