156 lines
4.1 KiB
Dart
156 lines
4.1 KiB
Dart
import 'package:flutter/material.dart';
|
|
import 'package:cashumit/utils/app_text_styles.dart';
|
|
|
|
/// Selector untuk akun sumber (revenue) — dipakai per-grup.
|
|
/// Tanpa label "Dari:" — hanya chip dropdown saja.
|
|
class SourceAccountSelector extends StatelessWidget {
|
|
final String sourceAccount;
|
|
final VoidCallback onSelectSource;
|
|
|
|
const SourceAccountSelector({
|
|
super.key,
|
|
required this.sourceAccount,
|
|
required this.onSelectSource,
|
|
});
|
|
|
|
@override
|
|
Widget build(BuildContext context) {
|
|
return GestureDetector(
|
|
onTap: onSelectSource,
|
|
child: Container(
|
|
width: double.infinity,
|
|
padding:
|
|
const EdgeInsets.symmetric(horizontal: 8.0, vertical: 6.0),
|
|
decoration: BoxDecoration(
|
|
border: Border.all(color: Colors.grey),
|
|
borderRadius: BorderRadius.circular(4.0),
|
|
),
|
|
child: Row(
|
|
children: [
|
|
Expanded(
|
|
child: Text(
|
|
sourceAccount,
|
|
style: CourierStyles.base,
|
|
overflow: TextOverflow.ellipsis,
|
|
),
|
|
),
|
|
const Icon(Icons.arrow_drop_down, size: 16),
|
|
],
|
|
),
|
|
),
|
|
);
|
|
}
|
|
}
|
|
|
|
/// Selector untuk akun tujuan (asset) — dipakai di level struk (dibagikan).
|
|
class DestinationAccountSelector extends StatelessWidget {
|
|
final String destinationAccount;
|
|
final VoidCallback onSelectDestination;
|
|
|
|
const DestinationAccountSelector({
|
|
super.key,
|
|
required this.destinationAccount,
|
|
required this.onSelectDestination,
|
|
});
|
|
|
|
@override
|
|
Widget build(BuildContext context) {
|
|
return _AccountChip(
|
|
label: 'Ke:',
|
|
value: destinationAccount,
|
|
onTap: onSelectDestination,
|
|
);
|
|
}
|
|
}
|
|
|
|
class _AccountChip extends StatelessWidget {
|
|
final String label;
|
|
final String value;
|
|
final VoidCallback onTap;
|
|
|
|
const _AccountChip({
|
|
required this.label,
|
|
required this.value,
|
|
required this.onTap,
|
|
});
|
|
|
|
@override
|
|
Widget build(BuildContext context) {
|
|
return Row(
|
|
crossAxisAlignment: CrossAxisAlignment.center,
|
|
children: [
|
|
Text(label, style: CourierStyles.bold),
|
|
const SizedBox(width: 8),
|
|
Expanded(
|
|
child: GestureDetector(
|
|
onTap: onTap,
|
|
child: Container(
|
|
padding: const EdgeInsets.symmetric(
|
|
horizontal: 8.0, vertical: 6.0),
|
|
decoration: BoxDecoration(
|
|
border: Border.all(color: Colors.grey),
|
|
borderRadius: BorderRadius.circular(4.0),
|
|
),
|
|
child: Row(
|
|
children: [
|
|
Expanded(
|
|
child: Text(
|
|
value,
|
|
style: CourierStyles.base,
|
|
overflow: TextOverflow.ellipsis,
|
|
),
|
|
),
|
|
const Icon(Icons.arrow_drop_down, size: 16),
|
|
],
|
|
),
|
|
),
|
|
),
|
|
),
|
|
],
|
|
);
|
|
}
|
|
}
|
|
|
|
/// Widget lama (compat) — menampilkan Dari + Ke berdampingan.
|
|
/// Tetap dipertahankan agar tidak merusak import lain.
|
|
class AccountSettingsWidget extends StatelessWidget {
|
|
final String sourceAccount;
|
|
final String destinationAccount;
|
|
final VoidCallback onSelectSource;
|
|
final VoidCallback onSelectDestination;
|
|
|
|
const AccountSettingsWidget({
|
|
super.key,
|
|
required this.sourceAccount,
|
|
required this.destinationAccount,
|
|
required this.onSelectSource,
|
|
required this.onSelectDestination,
|
|
});
|
|
|
|
@override
|
|
Widget build(BuildContext context) {
|
|
return Container(
|
|
width: double.infinity,
|
|
padding: const EdgeInsets.all(8.0),
|
|
color: Colors.white,
|
|
child: Row(
|
|
children: [
|
|
Expanded(
|
|
child: SourceAccountSelector(
|
|
sourceAccount: sourceAccount,
|
|
onSelectSource: onSelectSource,
|
|
),
|
|
),
|
|
const SizedBox(width: 16),
|
|
Expanded(
|
|
child: DestinationAccountSelector(
|
|
destinationAccount: destinationAccount,
|
|
onSelectDestination: onSelectDestination,
|
|
),
|
|
),
|
|
],
|
|
),
|
|
);
|
|
}
|
|
}
|