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

Adding Slider #18

Open
wants to merge 1 commit into
base: main
Choose a base branch
from
Open
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
30 changes: 20 additions & 10 deletions lib/friends.dart
Original file line number Diff line number Diff line change
Expand Up @@ -4,12 +4,14 @@ import 'package:flutter/material.dart';
import 'neubox.dart';

class Friends extends StatefulWidget {
final double finalAmt;
final String name;
final String percentage;
final String toPay;
final String slider;
const Friends({
Key? key,
required this.finalAmt,
required this.name,
required this.percentage,
required this.toPay,
Expand All @@ -21,8 +23,11 @@ class Friends extends StatefulWidget {
}

class _FriendsState extends State<Friends> {
double john_amt = 0;

@override
Widget build(BuildContext context) {
double finalAmt = widget.finalAmt;
return Container(
child: Padding(
padding: const EdgeInsets.all(12.0),
Expand Down Expand Up @@ -57,14 +62,14 @@ class _FriendsState extends State<Friends> {
SizedBox(
width: 10,
),
Text("40%",
style: TextStyle(
fontWeight: FontWeight.bold,
color: Color.fromARGB(255, 66, 66, 66))),
// Text(((john_amt / (widget.finalAmt)) * 100).toString(),
// style: TextStyle(
// fontWeight: FontWeight.bold,
// color: Color.fromARGB(255, 66, 66, 66))),
SizedBox(
width: 100,
),
Text("Rs 500",
Text("Rs ${john_amt}",
style: TextStyle(
fontWeight: FontWeight.bold,
color: Color.fromARGB(255, 66, 66, 66))),
Expand All @@ -74,16 +79,21 @@ class _FriendsState extends State<Friends> {
children: [
Slider(
min: 0,
max: 10,
max: finalAmt,
activeColor:
const Color.fromARGB(255, 45, 191, 244),
inactiveColor: Colors.grey,
value: 7,
onChanged: ((value) {})),
value: john_amt,
divisions: 10,
onChanged: ((value) {
setState(() {
john_amt = value;
});
})),
],
)
),
],
)
),
],
),
),
Expand Down
34 changes: 22 additions & 12 deletions lib/homepage.dart
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,10 @@ class Homepage extends StatefulWidget {
}

class _HomepageState extends State<Homepage> {
double foodAmt = 1000;
double tip_amount = 0;
double finalAmt = 0;

@override
Widget build(BuildContext context) {
return Scaffold(
Expand Down Expand Up @@ -55,8 +59,8 @@ class _HomepageState extends State<Homepage> {
fontWeight: FontWeight.bold,
color: Color.fromARGB(255, 82, 80, 80)),
),
const Text(
"Rs 1000",
Text(
foodAmt.toString(),
// ignore: unnecessary_const
style: const TextStyle(
fontSize: 20,
Expand All @@ -80,16 +84,22 @@ class _HomepageState extends State<Homepage> {
color: Color.fromARGB(255, 75, 75, 75))),
Slider(
min: 0,
max: 10,
max: 100,
divisions: 10,
activeColor: const Color.fromARGB(255, 241, 123, 80),
inactiveColor: Colors.grey,
value: 5,
onChanged: ((value) {})),
value: tip_amount,
label: (tip_amount * 10).toString(),
onChanged: ((value) {
setState(() {
tip_amount = value;
});
})),
const SizedBox(
width: 0,
),
const Text("20%"),
const Text("200")
// Text("${tip_amount.toString()}% "),
Text((tip_amount * 10).toString()),
],
),
// ignore: prefer_const_constructors
Expand All @@ -107,8 +117,8 @@ class _HomepageState extends State<Homepage> {
fontWeight: FontWeight.bold,
color: Color.fromARGB(255, 8, 8, 8)),
),
const Text(
"Rs 1200",
Text(
(foodAmt + (tip_amount*10)).toString(),
style: TextStyle(
fontSize: 20,
fontWeight: FontWeight.bold,
Expand All @@ -121,11 +131,11 @@ class _HomepageState extends State<Homepage> {
)),
),
Friends(
name: "John", percentage: "40%", toPay: "Rs 500", slider: "4"),
finalAmt: (foodAmt + (tip_amount*10)), name: "John", percentage: "40%", toPay: "Rs 500", slider: "4"),
Friends(
name: "Neha", percentage: "70%", toPay: "Rs 1500", slider: "7"),
finalAmt: (foodAmt + (tip_amount*10)), name: "Neha", percentage: "70%", toPay: "Rs 1500", slider: "7"),
Friends(
name: "Eren", percentage: "30%", toPay: "Rs 300", slider: "3"),
finalAmt: (foodAmt + (tip_amount*10)), name: "Eren", percentage: "30%", toPay: "Rs 300", slider: "3"),

// Padding(
// padding: const EdgeInsets.all(12.0),
Expand Down
31 changes: 12 additions & 19 deletions pubspec.lock
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ packages:
name: async
url: "https://pub.dartlang.org"
source: hosted
version: "2.8.2"
version: "2.9.0"
boolean_selector:
dependency: transitive
description:
Expand All @@ -21,21 +21,14 @@ packages:
name: characters
url: "https://pub.dartlang.org"
source: hosted
version: "1.2.0"
charcode:
dependency: transitive
description:
name: charcode
url: "https://pub.dartlang.org"
source: hosted
version: "1.3.1"
version: "1.2.1"
clock:
dependency: transitive
description:
name: clock
url: "https://pub.dartlang.org"
source: hosted
version: "1.1.0"
version: "1.1.1"
collection:
dependency: transitive
description:
Expand Down Expand Up @@ -70,7 +63,7 @@ packages:
name: fake_async
url: "https://pub.dartlang.org"
source: hosted
version: "1.3.0"
version: "1.3.1"
ffi:
dependency: transitive
description:
Expand Down Expand Up @@ -143,28 +136,28 @@ packages:
name: matcher
url: "https://pub.dartlang.org"
source: hosted
version: "0.12.11"
version: "0.12.12"
material_color_utilities:
dependency: transitive
description:
name: material_color_utilities
url: "https://pub.dartlang.org"
source: hosted
version: "0.1.4"
version: "0.1.5"
meta:
dependency: transitive
description:
name: meta
url: "https://pub.dartlang.org"
source: hosted
version: "1.7.0"
version: "1.8.0"
path:
dependency: transitive
description:
name: path
url: "https://pub.dartlang.org"
source: hosted
version: "1.8.1"
version: "1.8.2"
path_provider:
dependency: transitive
description:
Expand Down Expand Up @@ -246,7 +239,7 @@ packages:
name: source_span
url: "https://pub.dartlang.org"
source: hosted
version: "1.8.2"
version: "1.9.0"
stack_trace:
dependency: transitive
description:
Expand All @@ -267,21 +260,21 @@ packages:
name: string_scanner
url: "https://pub.dartlang.org"
source: hosted
version: "1.1.0"
version: "1.1.1"
term_glyph:
dependency: transitive
description:
name: term_glyph
url: "https://pub.dartlang.org"
source: hosted
version: "1.2.0"
version: "1.2.1"
test_api:
dependency: transitive
description:
name: test_api
url: "https://pub.dartlang.org"
source: hosted
version: "0.4.9"
version: "0.4.12"
typed_data:
dependency: transitive
description:
Expand Down