离子材料侧杆

时间:2015-06-12 14:33:53

标签: mobile material-design sidebar ionic-material

我正在尝试最近的Ionic框架,我想实现一个材料设计。我想做这样的事情

https://github.com/wasabeef/awesome-android-ui/blob/master/art/LDrawer.gif

这可能吗?

非常感谢。

1 个答案:

答案 0 :(得分:0)

这完全有可能,您只需要了解一些基本的scss和HTML。

这是我自己创建的侧面菜单

import { Component, OnInit } from '@angular/core';
import { MenuController } from '@ionic/angular';
import { Router } from '@angular/router';

@Component({
  selector: 'app-side-menu',
  templateUrl: './side-menu.component.html',
  styleUrls: ['./side-menu.component.scss'],
})
export class SideMenuComponent implements OnInit {

  constructor(private menu: MenuController, public router: Router) { }

  ngOnInit() {}

  navigateToDashboard() {
    this.router.navigate(['tabs/tab1'])
    console.log("Directed to dashboard")

  }

  navigateToProjects() {
    this.router.navigate(['projectspage'])
    console.log("Directed to Projects")
  }

  openFirst() {
    this.menu.enable(true, 'first');
    this.menu.open('first');
  }

  openEnd() {
    this.menu.open('end');
  }

  openCustom() {
    this.menu.enable(true, 'custom');
    this.menu.open('custom');
  }
  
}
img {
  border-radius: 50%;
  border: 1px solid #ddd;
  padding: 5px;
  left: initial;
  width: 150px;
  margin-left: 60px;
}

ion-card{
  margin-bottom:10px;
  margin-top: 11px;
  position: relative;
  
}

ion-menu{
  --background: linear-gradient(to right, rgb(201, 75, 75), rgb(75, 19, 79));
//filter: blur(8px);
}

ion-button{
  margin-bottom: 7px;
}

div{
  margin-bottom: 31px;
}




.my-custom-menu {
    --width: 500px;
  }
  
  
<ion-menu side="start"  content-id="main-content" swipe-gesture="true">


  <ion-card color="transparent">
    <img src="../../../assets/img/avatar.jpg" alt="Avatar">
    <ion-card-header>
      <ion-card-subtitle>Role</ion-card-subtitle>
      <ion-card-title color="light">UserName</ion-card-title>
    </ion-card-header>
  </ion-card>

  <div>
    <ion-button expand="full" color="#7c46ce" (click)="navigateToDashboard()">
      <ion-icon name="reader-outline"></ion-icon> &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; Dashboard
    </ion-button>

    <ion-button expand="full" color="#7c46ce">
      <ion-icon name="person-outline"></ion-icon>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; My profile
    </ion-button>

    <ion-button expand="full" color="#7c46ce" (click)="navigateToProjects()">
      <ion-icon name="bar-chart-outline"></ion-icon>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; Projects
    </ion-button>

    <ion-button expand="full" color="#7c46ce">
      <ion-icon name="pie-chart-outline"></ion-icon>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; Statistics
    </ion-button>
  </div>


  <div>

    <ion-button expand="full" color="#7c46ce">
      <ion-icon name="construct-outline"></ion-icon>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; Settings
    </ion-button>

    <ion-button expand="full" color="#7c46ce">
      <ion-icon name="log-out-outline"></ion-icon>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; Logout
    </ion-button>
  </div>



</ion-menu>



<div class="ion-page" id="main-content">
  <ion-header>
    <ion-toolbar>
      <ion-buttons slot="start">
        <ion-menu-button>
          <ion-icon name="menu"></ion-icon>
        </ion-menu-button>
      </ion-buttons>

    </ion-toolbar>
  </ion-header>

</div>

这是它的样子

enter image description here enter image description here