Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- import 'dart:async';
- import 'package:flutter/material.dart';
- import 'package:mallcomm_cms_flutter/main.dart';
- import 'package:mallcomm_cms_flutter/People/all_people.dart';
- import 'package:url_launcher/url_launcher.dart';
- import 'package:mallcomm_cms_flutter/Profile/user_profiles.dart';
- class PeopleDetails extends StatefulWidget {
- final String title;
- final Profile profile;
- PeopleDetails(this.title, this.profile);
- @override
- _PermissionsState createState()=> new _PermissionsState(profile);
- }
- class _PermissionsState extends State<PeopleDetails> {
- // Variables to store my switch values
- final Profile profile;
- _PermissionsState(this.profile);
- // onChanged handles the switch state whether its on or off
- void _onChangedVerified(bool value) {
- setState(() {
- profile.verifiedValue = value;
- });
- }
- void _onChangedApproved(bool value) {
- setState(() {
- profile.approvedValue = value;
- });
- }
- void _onChangedSecurityApproved(bool value) {
- setState(() {
- profile.securityApprovedValue = value;
- });
- }
- void _onChangedBlocked(bool value) {
- setState(() {
- profile.blockedValue = value;
- });
- }
- @override
- Widget build(BuildContext context) {
- void _launchDial() async {
- var url = "tel:" + profile.phoneNumber;
- if (await canLaunch(url))
- launch(url);
- else
- print('URL CAN NOT BE LAUNCHED');
- }
- void _launchEmail() async {
- var url = "mailto:" + profile.userEmail;
- if (await canLaunch(url))
- launch(url);
- else
- print('URL CAN NOT BE LAUNCHED');
- }
- return Scaffold(appBar: AppBar(
- title: Text("User Permissions"),
- ),
- body: Container(
- padding: EdgeInsets.all(8.0),
- child: Column(
- children: <Widget>[
- Row(
- children: <Widget>[
- Expanded(child: Text("Verified"
- ),
- ),
- Container(
- //https://www.youtube.com/watch?v=Z5lggEXYNCI
- child: Switch(value: profile.verifiedValue, onChanged: (bool value) {
- _onChangedVerified(value);
- }),
- ),
- ],
- ),
- Row(
- children: <Widget>[
- Expanded(
- child: Text("Approved"),
- ),
- Container(
- // Setting the value of the Switch to null if "profile.blockedValue" is true
- child: Switch(value: profile.approvedValue,onChanged: profile.blockedValue ? null : (bool value) {
- setState(() {
- profile.approvedValue=value;
- if(!profile.blockedValue)
- {
- profile.securityApprovedValue=false;
- }
- });(value);
- }),
- )
- ],
- ),
- Row(
- children: <Widget>[
- Expanded(
- child: Text("Security Approved"),
- ),
- Container(
- child: Switch(value: profile.securityApprovedValue, onChanged: profile.blockedValue ? null : (bool value){
- setState(() {
- profile.securityApprovedValue=value;
- if (value && !profile.approvedValue){
- profile.approvedValue= true;
- }
- });
- }),
- )
- ],
- ),
- Row(
- children: <Widget>[
- Expanded(
- child: Text("Blocked"),
- ),
- Container(
- child: Switch(value: profile.blockedValue, onChanged: (bool value){
- setState(() {
- profile.blockedValue=value;
- // if blockedValue = true then set securityApprovedValue & approvedValue to false
- if(profile.blockedValue)
- {
- profile.securityApprovedValue=false;
- profile.approvedValue=false;
- }
- });(value);
- }),
- )
- ],
- ),
- Row(
- mainAxisAlignment: MainAxisAlignment.spaceEvenly,
- children: <Widget>[
- CustomColumn.buildButtonColumn(Icons.lock_open, 'UNLOCK', Colors.red),
- InkWell(
- splashColor: Colors.greenAccent,
- onTap: _launchEmail, child: CustomColumn.buildButtonColumn(Icons.mail, 'EMAIL', Colors.amber),
- ),
- InkWell(
- splashColor: Colors.yellowAccent,
- onTap: _launchDial, child: CustomColumn.buildButtonColumn(Icons.call, 'CALL', Colors.green),
- ),
- ],
- ),Column(children: <Widget>[Padding(
- padding: EdgeInsets.only(top: 20.0),
- ),
- RaisedButton(child: Text('Grant CMS Access'),color: Theme.of(context).primaryColor,
- textColor: Colors.white,
- onPressed: (){// call my simple duialog here}
- ),
- ],
- )
- ],
- ),
- ),
- );
- }
- }
- class CustomColumn {
- // Custom Column
- static Column buildButtonColumn(IconData icon, String label, Color color) {
- return new Column(
- mainAxisSize: MainAxisSize.min,
- mainAxisAlignment: MainAxisAlignment.center,
- children: <Widget>[Icon(icon, color: color, size: 30.0,
- ),
- Container(
- margin: const EdgeInsets.only(top: 8.0),
- child: Text(
- label, style: TextStyle(
- fontSize: 12.0,
- fontWeight: FontWeight.w400,
- ),
- ),
- )
- ],
- );
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement