Appearance
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 detectiondart:math- Random number generationflutter/gestures.dart- Gesture recognitionflutter/material.dart- Flutter UI componentsflutter/services.dart- System servicesget/get.dart- State managementget_storage/get_storage.dart- Local storagepin_code_fields/pin_code_fields.dart- PIN input fieldpermission_handler/permission_handler.dart- Permission management
Key Components
Controllers
authController- Manages authenticationmeetingsController- Handles meeting accessrealTimeController- Manages real-time communicationmessagesController- Handles messagingdigilensController- Manages DigiLens features
State Variables
pin- Current PIN valuetextEditingController- Controls PIN input fielddataList- Color-coded keyboard datalist- Numeric keyboard buttonsactionButtons- 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 managementflutter/material.dart- UI componentspin_code_fields- PIN inputpermission_handler- Permission managementget_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
authControllerfor authentication - Integrates with
meetingsControllerfor meeting access - Uses
realTimeControllerfor communication - Integrates with
digilensControllerfor voice commands - Utilizes
HlkUtilsfor layout helpers
Voice Command Support
- Color names as voice commands
- Number entry through voice
- Clear and Delete commands