Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

New convert screen #7

Merged
merged 1 commit into from
May 11, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
128 changes: 128 additions & 0 deletions lib/pages/home/convert.dart
Original file line number Diff line number Diff line change
@@ -0,0 +1,128 @@
import 'package:flutter/material.dart';

class ConvertScreen extends StatefulWidget {
final String title;

const ConvertScreen({
Key? key,
required this.title,
}) : super(key: key);

@override
State<ConvertScreen> createState() => _ConvertScreenState();
}

class _ConvertScreenState extends State<ConvertScreen> {
List<String> items = ["Item 1", "Item 2", "Item 3","Item 4", "Item 5", "Item 6","Item 7", "Item 8", "Item 9"]; // Sample list of items
List<String> selectedCheckboxes = [];
String? selectedRadio;

@override
Widget build(BuildContext context) {
return Scaffold(
appBar: AppBar(
backgroundColor: Theme.of(context).colorScheme.inversePrimary,
title: Text(widget.title),
),
body: Padding(
padding: const EdgeInsets.all(16.0),
child: Column(
crossAxisAlignment: CrossAxisAlignment.start,
children: [
const Text(
"Convert",
style: TextStyle(fontSize: 20, fontWeight: FontWeight.bold),
),
Expanded(
child: Card(
margin: EdgeInsets.only(bottom: 20),
child: Padding(
padding: const EdgeInsets.all(10.0),
child: ListView.separated(
separatorBuilder: (context, index) => Visibility(visible: selectedRadio != items[index], child: const Divider()),
itemCount: items.length,
itemBuilder: (context, index) {
final item = items[index];
return Visibility(
visible: selectedRadio != items[index],
child: SizedBox(
height: 40,
child: CheckboxListTile(
contentPadding: EdgeInsets.zero, // Remove extra padding
title: Padding(
padding: const EdgeInsets.symmetric(horizontal: 16.0),
child: Text(item),
),
value: selectedCheckboxes.contains(item),
onChanged: (value) {
setState(() {
if (value != null && value) {
selectedCheckboxes.add(item);
} else {
selectedCheckboxes.remove(item);
}
});
},
),
),
);
},
),
),
),
),
const Divider(height: 10,),
const SizedBox(height: 10,),
const Text(
"To",
style: TextStyle(fontSize: 20, fontWeight: FontWeight.bold),
),
Expanded(
child: Card(
margin: EdgeInsets.only(bottom: 20),
child: Padding(
padding: const EdgeInsets.all(10.0),
child: ListView.separated(

separatorBuilder: (context, index) => Visibility(visible: !selectedCheckboxes.contains(items[index]), child: const Divider()),
itemCount: items.length,
itemBuilder: (context, index) {
final item = items[index];
return Visibility(
visible: !selectedCheckboxes.contains(items[index]),
child: SizedBox(
height: 40,
child: RadioListTile<String>(
contentPadding: EdgeInsets.zero,
title: Padding(
padding: const EdgeInsets.symmetric(horizontal: 16.0),
child: Text(item),
),
value: item,
groupValue: selectedRadio,
onChanged: (value) {
setState(() {
selectedRadio = value;
});
},
controlAffinity: ListTileControlAffinity.trailing, // Align radio buttons to the right
),
),
);
},
),
),
),

),

Center(child: TextButton(onPressed: Convert, child: const Text("Convert")))
],
),
),
);
}

void Convert() {
}
}
2 changes: 1 addition & 1 deletion lib/pages/home/home.dart
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,7 @@ class _MyHomePageState extends State<MyHomePage> {
Navigator.push(
context,
MaterialPageRoute(
builder: (context) => const NewTransScreenP1(),
builder: (context) => const NewTransScreen(),
),
);
},
Expand Down
Loading