Skip to content

Commit

Permalink
Initial Commit (Basic Framework and Dummy Data)
Browse files Browse the repository at this point in the history
  • Loading branch information
MXC1 committed Feb 10, 2020
1 parent 9f7d180 commit 80390fc
Show file tree
Hide file tree
Showing 64 changed files with 1,470 additions and 75 deletions.
24 changes: 22 additions & 2 deletions src/app/app-routing.module.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,28 @@ import { NgModule } from '@angular/core';
import { PreloadAllModules, RouterModule, Routes } from '@angular/router';

const routes: Routes = [
{ path: '', redirectTo: 'home', pathMatch: 'full' },
{ path: 'home', loadChildren: () => import('./home/home.module').then( m => m.HomePageModule)},
{ path: '', redirectTo: 'tabs/feed', pathMatch: 'full' },
{
path: 'auth',
loadChildren: () => import('./auth/auth.module').then(m => m.AuthPageModule)
},
{
path: 'tabs',
loadChildren: () => import('./tabs/tabs.module').then(m => m.TabsPageModule)
},
{
path: 'post-detail',
children: [
{
path: '',
loadChildren: () => import('./tabs/tabs.module').then(m => m.TabsPageModule)
},
{
path: ':postId',
loadChildren: () => import('./post-detail/post-detail.module').then(m => m.PostDetailPageModule)
}
]
},
];

@NgModule({
Expand Down
25 changes: 25 additions & 0 deletions src/app/auth/auth-routing.module.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
import { NgModule } from '@angular/core';
import { Routes, RouterModule } from '@angular/router';

import { AuthPage } from './auth.page';

const routes: Routes = [
{
path: '',
component: AuthPage
},
{
path: 'login',
loadChildren: () => import('./login/login.module').then( m => m.LoginPageModule)
},
{
path: 'register',
loadChildren: () => import('./register/register.module').then( m => m.RegisterPageModule)
}
];

@NgModule({
imports: [RouterModule.forChild(routes)],
exports: [RouterModule],
})
export class AuthPageRoutingModule {}
19 changes: 8 additions & 11 deletions src/app/home/home.module.ts → src/app/auth/auth.module.ts
Original file line number Diff line number Diff line change
@@ -1,23 +1,20 @@
import { NgModule } from '@angular/core';
import { CommonModule } from '@angular/common';
import { IonicModule } from '@ionic/angular';
import { FormsModule } from '@angular/forms';
import { RouterModule } from '@angular/router';

import { HomePage } from './home.page';
import { IonicModule } from '@ionic/angular';

import { AuthPageRoutingModule } from './auth-routing.module';

import { AuthPage } from './auth.page';

@NgModule({
imports: [
CommonModule,
FormsModule,
IonicModule,
RouterModule.forChild([
{
path: '',
component: HomePage
}
])
AuthPageRoutingModule
],
declarations: [HomePage]
declarations: [AuthPage]
})
export class HomePageModule {}
export class AuthPageModule {}
9 changes: 9 additions & 0 deletions src/app/auth/auth.page.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
<ion-header>
<ion-toolbar>
<ion-title>auth</ion-title>
</ion-toolbar>
</ion-header>

<ion-content>

</ion-content>
Empty file added src/app/auth/auth.page.scss
Empty file.
Original file line number Diff line number Diff line change
@@ -1,19 +1,19 @@
import { async, ComponentFixture, TestBed } from '@angular/core/testing';
import { IonicModule } from '@ionic/angular';

import { HomePage } from './home.page';
import { AuthPage } from './auth.page';

describe('HomePage', () => {
let component: HomePage;
let fixture: ComponentFixture<HomePage>;
describe('AuthPage', () => {
let component: AuthPage;
let fixture: ComponentFixture<AuthPage>;

beforeEach(async(() => {
TestBed.configureTestingModule({
declarations: [ HomePage ],
declarations: [ AuthPage ],
imports: [IonicModule.forRoot()]
}).compileComponents();

fixture = TestBed.createComponent(HomePage);
fixture = TestBed.createComponent(AuthPage);
component = fixture.componentInstance;
fixture.detectChanges();
}));
Expand Down
15 changes: 15 additions & 0 deletions src/app/auth/auth.page.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
import { Component, OnInit } from '@angular/core';

@Component({
selector: 'app-auth',
templateUrl: './auth.page.html',
styleUrls: ['./auth.page.scss'],
})
export class AuthPage implements OnInit {

constructor() { }

ngOnInit() {
}

}
27 changes: 27 additions & 0 deletions src/app/auth/auth.service.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
import { Injectable } from '@angular/core';

@Injectable({
providedIn: 'root'
})
export class AuthService {
private authenticated = true;
private userId = 'u1';

get isAuthenticated() {
return this.authenticated;
}

get getUserId() {
return this.userId;
}

login() {
this.authenticated = true;
}

logout() {
this.authenticated = false;
}

constructor() { }
}
17 changes: 17 additions & 0 deletions src/app/auth/login/login-routing.module.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
import { NgModule } from '@angular/core';
import { Routes, RouterModule } from '@angular/router';

import { LoginPage } from './login.page';

const routes: Routes = [
{
path: '',
component: LoginPage
}
];

@NgModule({
imports: [RouterModule.forChild(routes)],
exports: [RouterModule],
})
export class LoginPageRoutingModule {}
21 changes: 21 additions & 0 deletions src/app/auth/login/login.module.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
import { NgModule } from '@angular/core';
import { CommonModule } from '@angular/common';
import { FormsModule, ReactiveFormsModule } from '@angular/forms';

import { IonicModule } from '@ionic/angular';

import { LoginPageRoutingModule } from './login-routing.module';

import { LoginPage } from './login.page';

@NgModule({
imports: [
CommonModule,
FormsModule,
ReactiveFormsModule,
IonicModule,
LoginPageRoutingModule
],
declarations: [LoginPage]
})
export class LoginPageModule {}
38 changes: 38 additions & 0 deletions src/app/auth/login/login.page.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
<ion-header>
<ion-toolbar>
<ion-title class="ion-text-center">Log in</ion-title>
</ion-toolbar>
</ion-header>

<ion-content>
<form [formGroup]="form">
<ion-grid>
<ion-row>
<ion-col class="ion-text-center">
<p>Sign in to see the latest content</p>
</ion-col>
</ion-row>
<ion-row class="ion-justify-content-center">
<ion-col size="6">
<ion-item>
<ion-label class="ion-text-center" position="floating">Email/Username</ion-label>
<ion-input type="text" formControlName="login"></ion-input>
</ion-item>
</ion-col>
</ion-row>
<ion-row class="ion-justify-content-center">
<ion-col size="6">
<ion-item>
<ion-label class="ion-text-center" position="floating">Password</ion-label>
<ion-input type="password" formControlName="password"></ion-input>
</ion-item>
</ion-col>
</ion-row>
<ion-row class="ion-text-center" style="padding-top: 10px;">
<ion-col>
<ion-button type="submit" (click)="onLogin()">Log in</ion-button>
</ion-col>
</ion-row>
</ion-grid>
</form>
</ion-content>
Empty file.
24 changes: 24 additions & 0 deletions src/app/auth/login/login.page.spec.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
import { async, ComponentFixture, TestBed } from '@angular/core/testing';
import { IonicModule } from '@ionic/angular';

import { LoginPage } from './login.page';

describe('LoginPage', () => {
let component: LoginPage;
let fixture: ComponentFixture<LoginPage>;

beforeEach(async(() => {
TestBed.configureTestingModule({
declarations: [ LoginPage ],
imports: [IonicModule.forRoot()]
}).compileComponents();

fixture = TestBed.createComponent(LoginPage);
component = fixture.componentInstance;
fixture.detectChanges();
}));

it('should create', () => {
expect(component).toBeTruthy();
});
});
41 changes: 41 additions & 0 deletions src/app/auth/login/login.page.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,41 @@
import { Component, OnInit } from '@angular/core';
import { FormGroup, FormControl, Validators } from '@angular/forms';
import { AuthService } from '../auth.service';
import { Router } from '@angular/router';

@Component({
selector: 'app-login',
templateUrl: './login.page.html',
styleUrls: ['./login.page.scss'],
})
export class LoginPage implements OnInit {
form: FormGroup;

constructor(private authService: AuthService, private router: Router) { }

ngOnInit() {
this.form = new FormGroup({
login: new FormControl(null, {
updateOn: 'blur',
validators: [Validators.required, Validators.maxLength(255)]
}),
password: new FormControl(null, {
updateOn: 'blur',
validators: [Validators.required, Validators.maxLength(255)]
})
});
}

onLogin() {
if (!this.form.valid) {
return;
}

const login = this.form.value.login;
const password = this.form.value.password;

this.authService.login();
this.form.reset();
this.router.navigateByUrl('/tabs/feed');
}
}
17 changes: 17 additions & 0 deletions src/app/auth/register/register-routing.module.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
import { NgModule } from '@angular/core';
import { Routes, RouterModule } from '@angular/router';

import { RegisterPage } from './register.page';

const routes: Routes = [
{
path: '',
component: RegisterPage
}
];

@NgModule({
imports: [RouterModule.forChild(routes)],
exports: [RouterModule],
})
export class RegisterPageRoutingModule {}
21 changes: 21 additions & 0 deletions src/app/auth/register/register.module.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
import { NgModule } from '@angular/core';
import { CommonModule } from '@angular/common';
import { FormsModule, ReactiveFormsModule } from '@angular/forms';

import { IonicModule } from '@ionic/angular';

import { RegisterPageRoutingModule } from './register-routing.module';

import { RegisterPage } from './register.page';

@NgModule({
imports: [
CommonModule,
FormsModule,
ReactiveFormsModule,
IonicModule,
RegisterPageRoutingModule
],
declarations: [RegisterPage]
})
export class RegisterPageModule {}
Loading

0 comments on commit 80390fc

Please sign in to comment.