50 lines
1.2 KiB
Dart
50 lines
1.2 KiB
Dart
import 'package:flutter/material.dart';
|
|
|
|
class OpacityDialog extends StatefulWidget {
|
|
final double initial;
|
|
const OpacityDialog({super.key, required this.initial});
|
|
@override
|
|
_OpacityDialogState createState() => _OpacityDialogState();
|
|
}
|
|
|
|
class _OpacityDialogState extends State<OpacityDialog> {
|
|
late double val;
|
|
@override
|
|
void initState() {
|
|
super.initState();
|
|
val = widget.initial;
|
|
}
|
|
|
|
@override
|
|
Widget build(BuildContext context) {
|
|
return AlertDialog(
|
|
title: Text('Opacity Watermark'),
|
|
content: Column(
|
|
mainAxisSize: MainAxisSize.min,
|
|
children: [
|
|
Slider(
|
|
value: val,
|
|
min: 0.1,
|
|
max: 1.0,
|
|
divisions: 9,
|
|
label: '${(val * 100).toStringAsFixed(0)}%',
|
|
onChanged: (v) => setState(() => val = v),
|
|
),
|
|
SizedBox(height: 8),
|
|
Text('Preview: ${(val * 100).toStringAsFixed(0)}%'),
|
|
],
|
|
),
|
|
actions: [
|
|
TextButton(
|
|
onPressed: () => Navigator.pop(context),
|
|
child: Text('Batal'),
|
|
),
|
|
TextButton(
|
|
onPressed: () => Navigator.pop(context, val),
|
|
child: Text('OK'),
|
|
),
|
|
],
|
|
);
|
|
}
|
|
}
|