import QtQuick 2.12
import QtQuick.Controls 2.12
import QtQuick.Layouts 1.12

import LibreHub 1.0

Page {
  anchors.fill: parent;
  visible: API.is_authenticated;

  header: ToolBar{
//    ToolButton {
//      anchors.verticalCenter: parent.verticalCenter;
//      anchors.right: parent.right;
//      anchors.rightMargin: 10;
//      icon.source: "qrc:/icons/account_circle_white_24dp.svg";
//    }

    Label {
      anchors.centerIn: parent;
      text: (()=>{
             switch(main_swipe.currentIndex) {
               case 0: return "Profile";
               case 1: return "Chats";
               case 2: return "Contacts";
               case 3: return "Groups";
             }
             })();
    }

  }

  footer: ToolBar {
    RowLayout {
      anchors.centerIn: parent;

      ToolButton {
        icon.source: "qrc:/icons/account_circle_white_24dp.svg";
        icon.color: (main_swipe.currentIndex == 0)? app_root.accent : app_root.highlight_text_color;
        onClicked: main_swipe.currentIndex = 0;
      }

      ToolButton {
        icon.source: "qrc:/icons/chat_white_24dp.svg";
        icon.color: (main_swipe.currentIndex == 1)? app_root.accent : app_root.highlight_text_color;
        onClicked: main_swipe.currentIndex = 1;
      }

      ToolButton {
        icon.source: "qrc:/icons/contacts_white_24dp.svg";
        icon.color: (main_swipe.currentIndex == 2)? app_root.accent : app_root.highlight_text_color;
        onClicked: main_swipe.currentIndex = 2;
      }

      ToolButton {
        icon.source: "qrc:/icons/groups_white_24dp.svg";
        icon.color: (main_swipe.currentIndex == 3)? app_root.accent : app_root.highlight_text_color;
        onClicked: main_swipe.currentIndex = 3;
      }

    }
  }

  SwipeView {
    id: main_swipe;
    anchors.fill: parent;

    Page { // Profile
      ColumnLayout {
        width: parent.width
        RowLayout {
          Layout.fillWidth: true;
          Label {text: "Ninckname: "}
          TextField { Layout.fillWidth: true; text: API.account_profile.nickname.toString(); placeholderText: "Enter your nickname";}
        }
        RowLayout {
          Layout.fillWidth: true;
          Label {text: "Name: "}
          TextField { Layout.fillWidth: true; text: API.account_profile.name.toString(); placeholderText: "Enter your name";}
        }
        RowLayout {
          Layout.fillWidth: true;
          Label {text: "Second name: "}
          TextField { Layout.fillWidth: true; text: API.account_profile.second_name.toString(); placeholderText: "Enter your second name";}
        }
        ToolButton {
          Layout.fillWidth: true;
          text: "Save changes";
        }
      }

    }
    Page {}
    Page {}
    Page {}
  }
}
