41 lines
1.0 KiB
Dart
41 lines
1.0 KiB
Dart
// lib/widgets/encrypt_audio_button.dart
|
|
|
|
import 'package:flutter/material.dart';
|
|
import '../services/audio_handler.dart';
|
|
|
|
class EncryptAudioButton extends StatefulWidget {
|
|
final AudioHandler audioHandler;
|
|
|
|
const EncryptAudioButton({Key? key, required this.audioHandler}) : super(key: key);
|
|
|
|
@override
|
|
_EncryptAudioButtonState createState() => _EncryptAudioButtonState();
|
|
}
|
|
|
|
class _EncryptAudioButtonState extends State<EncryptAudioButton> {
|
|
bool _isEncrypted = false;
|
|
|
|
void _toggleEncryption() {
|
|
setState(() {
|
|
_isEncrypted = !_isEncrypted;
|
|
if (_isEncrypted) {
|
|
widget.audioHandler.enableEncryption();
|
|
} else {
|
|
widget.audioHandler.disableEncryption();
|
|
}
|
|
});
|
|
}
|
|
|
|
@override
|
|
Widget build(BuildContext context) {
|
|
return IconButton(
|
|
icon: Icon(
|
|
_isEncrypted ? Icons.lock : Icons.lock_open,
|
|
color: Colors.blueAccent,
|
|
),
|
|
onPressed: _toggleEncryption,
|
|
tooltip: _isEncrypted ? 'Disable Encryption' : 'Enable Encryption',
|
|
);
|
|
}
|
|
}
|