Skip to content

Overview

  • File: lib/views/pin_page.dart

The pin_page.dart file implements a secure PIN entry interface for the HVC XR application. It provides a customizable numeric keypad with color-coded buttons, voice command support, and secure PIN validation for both login and meeting access.

Class Structure

dart
class PinPage extends StatefulWidget {
  static const String routeName = '/PinPage';
  final PinType pinType;

  const PinPage({Key? key, required this.pinType}) : super(key: key);
}

class _PinPageState extends State<PinPage> {
  // State implementation
}

class KeyboardItem extends StatelessWidget {
  final String number;
  final KeyBoardData keyBoardData;
  final Function(String) onPressed;
}

class KeyBoardData {
  final Color color;
  final String colorName;
}

Dependencies

  • dart:io - Platform detection
  • dart:math - Random number generation
  • flutter/gestures.dart - Gesture recognition
  • flutter/material.dart - Flutter UI components
  • flutter/services.dart - System services
  • get/get.dart - State management
  • get_storage/get_storage.dart - Local storage
  • pin_code_fields/pin_code_fields.dart - PIN input field
  • permission_handler/permission_handler.dart - Permission management

Key Components

Controllers

  • authController - Manages authentication
  • meetingsController - Handles meeting access
  • realTimeController - Manages real-time communication
  • messagesController - Handles messaging
  • digilensController - Manages DigiLens features

State Variables

  • pin - Current PIN value
  • textEditingController - Controls PIN input field
  • dataList - Color-coded keyboard data
  • list - Numeric keyboard buttons
  • actionButtons - Clear and Delete buttons

Core Functionality

PIN Entry and Validation

dart
onCompleted: (v) async {
  hideKeyBoard();
  if (widget.pinType == PinType.login) {
    await authController.login(authController.scannerResult.value.url, pin)
        .whenComplete(() async {
      // Handle login success
    });
  } else if (widget.pinType == PinType.meeting) {
    meetingsController.joinMeetingDto.value.pin = pin;
    // Handle meeting join
  }
}

Voice Command Registration

dart
for (var e in list) {
  var item = e as KeyboardItem;
  var key = item.keyBoardData.colorName.toLowerCase();
  var f = () {
    item.onPressed(item.number);
    setState(() {});
  };
  voiceCommandMap[key] = () => hvcDebounce(f, key);
}

Keyboard Setup

dart
void setUp() {
  // Add number buttons 1-9
  for (int i = 1; i < dataList.length; i++) {
    list.add(
      KeyboardItem(
        keyBoardData: dataList[i],
        number: '$i',
        onPressed: (value) {
          pin = pin + value;
          textEditingController.text = pin;
          hideKeyBoard();
        },
      ),
    );
  }
  // Add action buttons
}

UI Components

Main Layout

  • PIN input field with 4 digits
  • Color-coded numeric keypad
  • Clear and Delete buttons
  • Loading indicator

Dynamic Elements

  • Responsive layout based on orientation
  • Color-coded buttons with numbers and color names
  • Secure PIN input field
  • Loading state indicators

State Management

  • Uses GetX for reactive state management
  • Manages PIN state locally
  • Handles loading states through controllers
  • Manages voice command state

Security Features

  • Secure random number generation for keypad
  • PIN masking
  • Permission validation
  • Secure storage handling

Dependencies

  • get - State management
  • flutter/material.dart - UI components
  • pin_code_fields - PIN input
  • permission_handler - Permission management
  • get_storage - Local storage

Styling

  • Follow application theme
  • Use consistent color scheme
  • Implement responsive layouts
  • Handle different screen sizes
  • Support orientation changes

Integration Points

  • Connects with authController for authentication
  • Integrates with meetingsController for meeting access
  • Uses realTimeController for communication
  • Integrates with digilensController for voice commands
  • Utilizes HlkUtils for layout helpers

Voice Command Support

  • Color names as voice commands
  • Number entry through voice
  • Clear and Delete commands

Released under the MIT License.