Skip to content

Swtich tile Done #293

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

Open
wants to merge 16 commits into
base: master
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
3 changes: 2 additions & 1 deletion lib/main.dart
Original file line number Diff line number Diff line change
Expand Up @@ -11,11 +11,11 @@ void main() {
class MyApp extends StatefulWidget {
@override
State<StatefulWidget> createState() => _MyAppState();

}

class _MyAppState extends State<MyApp> {
ThemeProvider themeChangeProvider = new ThemeProvider();

@override
void initState() {
super.initState();
Expand All @@ -36,6 +36,7 @@ class _MyAppState extends State<MyApp> {
child: Consumer<ThemeProvider>(
builder: (BuildContext context, value, Widget? child) {
return MaterialApp(
debugShowCheckedModeBanner: false,
title: 'Fludget',
theme: ThemeFactory.getTheme(themeChangeProvider.themeMode),
home: SplashScreen(),
Expand Down
230 changes: 230 additions & 0 deletions lib/routes/switchlist_tile.dart
Original file line number Diff line number Diff line change
@@ -0,0 +1,230 @@
import 'package:fludget/Models/codeString.dart';
import 'package:flutter/cupertino.dart';
import 'package:flutter/material.dart';
class SwitchListTileWidget extends StatefulWidget {
const SwitchListTileWidget({Key? key}) : super(key: key);

@override
_SwitchListTileWidgetState createState() => _SwitchListTileWidgetState();
}

class _SwitchListTileWidgetState extends State<SwitchListTileWidget> {
bool _flutter = false;
bool _switched = false;
bool ss =false;
@override
Widget build(BuildContext context) {

return Container(
padding:EdgeInsets.only(left: 10,right: 10,top: 10) ,
alignment: Alignment.topCenter,
child: Card(
color: Colors.white,
child: Column(
children: [
Container(
decoration: BoxDecoration(
boxShadow: [
BoxShadow(
color: Colors.grey,
offset: const Offset(
1.0,
1.0,
), //Offset
blurRadius: 1.0,
spreadRadius: 1.0,
), //BoxShadow
BoxShadow(
color: Colors.white,
offset: const Offset(0.0, 0.0),
blurRadius: 0.0,
spreadRadius: 0.0,
),],

),
child: SwitchListTile(
title: Text('Fludget',style: TextStyle(
color: Theme.of(context).primaryColor,
fontWeight: FontWeight.w800,
fontSize: 20
),
),
value: ss,
selectedTileColor: Colors.cyanAccent,
activeColor: Theme.of(context).primaryColor,
inactiveTrackColor: Colors.red,

onChanged: (bool value) {
setState(() {
ss = value;
});
},
secondary: Icon(Icons.flutter_dash),
subtitle: Text('HacktoberFest 2021',style: TextStyle(
color: Colors.blueGrey[600],
),
),
controlAffinity: ListTileControlAffinity.trailing,
),
),
Container(
height:10,
),
Container(
decoration: BoxDecoration(
boxShadow: [
BoxShadow(
color: Colors.grey,
offset: const Offset(
1.0,
1.0,
), //Offset
blurRadius: 1.0,
spreadRadius: 1.0,
), //BoxShadow
BoxShadow(
color: Colors.white,
offset: const Offset(0.0, 0.0),
blurRadius: 0.0,
spreadRadius: 0.0,
),],

),
child: SwitchListTile(
title: Text('Tap Here',style: TextStyle(
color: Theme.of(context).primaryColor,
fontWeight: FontWeight.w800,
fontSize: 20
),
),
value: _flutter,
activeColor: Theme.of(context).primaryColor,
inactiveTrackColor: Colors.red,
onChanged: (bool value) {
setState(() {
_flutter = value;
});
},
secondary: Image.asset("assets/images/meme.png",width: 60,),
subtitle: Text('HacktoberFest 2021',style: TextStyle(
color: Colors.blueGrey[600],
),
),
activeThumbImage: NetworkImage("https://yt3.ggpht.com/ytc/AKedOLT-J2PfenC8ygtqUrmpllUa2sQ-tUrvcRIfxpSU=s900-c-k-c0x00ffffff-no-rj"),
controlAffinity: ListTileControlAffinity.trailing,
inactiveThumbImage: NetworkImage("https://i.pinimg.com/564x/ce/15/58/ce15584f4a9aaf701630a8902c6302c2.jpg"),
),
),
Container(
height:10,
),
Container(
decoration: BoxDecoration(
boxShadow: [
BoxShadow(
color: Colors.grey,
offset: const Offset(
1.0,
1.0,
), //Offset
blurRadius: 1.0,
spreadRadius: 1.0,
), //BoxShadow
BoxShadow(
color: Colors.white,
offset: const Offset(0.0, 0.0),
blurRadius: 0.0,
spreadRadius: 0.0,
),],

),
child: SwitchListTile(

title: Text('Allow BluetTooth',style: TextStyle(
color: Theme.of(context).primaryColor,
fontWeight: FontWeight.w800,
fontSize: 20
),
),
value: _switched,
activeColor: Theme.of(context).primaryColor,
inactiveTrackColor: Colors.red,
onChanged: (bool value) {
setState(() {
_switched= value;
});
},
secondary: Icon(Icons.bluetooth,color: Theme.of(context).primaryColor,),
subtitle: Text('Enable Switch to Access bluetooth',style: TextStyle(
color: Colors.blueGrey[600],
),
),
activeThumbImage: NetworkImage("https://www.pngmart.com/files/15/Happy-Face-Emoji-PNG-File.png"),
controlAffinity: ListTileControlAffinity.trailing,
inactiveThumbImage: NetworkImage("https://www.pngmart.com/files/1/Sad-Emoji-PNG-HD.png"),
),
),

],
),
),
);
}
}



class SwitchListTileDescription extends StatelessWidget {
const SwitchListTileDescription ({Key? key}) : super(key: key);

@override
Widget build(BuildContext context) {
return SingleChildScrollView(
child: Padding(
padding: const EdgeInsets.all(8.0),
child: Container(
margin: EdgeInsets.all(10),
alignment: Alignment.center,
child: Text(
'SwitchListTile is a widget that wraps a ListTile and a Switch. It iss usually used as a child of a ListView where the content has a Switch widget. A common usage is for displaying an item in a setting page where the user can toggle a particular setting on and off. '
,style: Theme.of(context).textTheme.headline6,
),
),
),
);
}
}


class SwitchListTileCode extends CodeString {
const SwitchListTileCode();
@override
String buildCodeString() {
return """ SwitchListTile(

title: Text('Allow BluetTooth',style: TextStyle(
color: Colors.blue,
fontWeight: FontWeight.w800,
fontSize: 20
),
),
value: _switched,
activeColor: Theme.of(context).primaryColor,
inactiveTrackColor: Colors.blueGrey,
onChanged: (bool value) {
setState(() {
_switched= value;
});
},
secondary: Icon(Icons.bluetooth,color: Colors.blue,),
subtitle: Text('Enable Swithch to Access bluetooth',style: TextStyle(
color: Colors.blueGrey[600],
),
),
activeThumbImage: NetworkImage("https://www.pngmart.com/files/15/Happy-Face-Emoji-PNG-File.png"),
controlAffinity: ListTileControlAffinity.trailing,
inactiveThumbImage: NetworkImage("https://www.pngmart.com/files/1/Sad-Emoji-PNG-HD.png"),
),
""";
}
}
22 changes: 12 additions & 10 deletions lib/widgetList.dart
Original file line number Diff line number Diff line change
Expand Up @@ -65,7 +65,6 @@ import 'package:fludget/routes/gridList.dart';
import 'package:fludget/routes/hero.dart';
import 'package:fludget/routes/icon.dart';
import 'package:fludget/routes/image.dart';
import 'package:fludget/routes/image_filtered.dart';
import 'package:fludget/routes/indexedStack.dart';
import 'package:fludget/routes/limited_box.dart';
import 'package:fludget/routes/linearProgressIndicator.dart';
Expand Down Expand Up @@ -93,6 +92,7 @@ import 'package:fludget/routes/spacer.dart';
import 'package:fludget/routes/stack.dart';
import 'package:fludget/routes/streamBuilder.dart';
import 'package:fludget/routes/switch.dart';
import 'package:fludget/routes/switchlist_tile.dart';
import 'package:fludget/routes/table.dart';
import 'package:fludget/routes/text.dart';
import 'package:fludget/routes/textButton.dart';
Expand All @@ -104,9 +104,9 @@ import 'package:fludget/routes/togglebutton.dart';
import 'package:fludget/routes/visibilityWidget.dart';
import 'package:fludget/routes/wrap.dart';
import 'package:fludget/routes/simple_dialog.dart';
import 'package:fludget/tooltip.dart';
import 'package:flutter/material.dart';
import 'package:fludget/routes/rotatedBox.dart';
import 'package:flutter/material.dart';
import 'Models/widgetModel.dart';
import 'routes/autoComplete.dart';
import 'routes/BottomNavigationBar.dart';
Expand Down Expand Up @@ -229,14 +229,6 @@ const List<WidgetModel> widgets = [
link: "https://api.flutter.dev/flutter/widgets/Image-class.html",
category: [WidgetCategoy.Assets, WidgetCategoy.Basics],
codeString: ImageCode()),
WidgetModel(
name: "ImageFilter",
subtitle: "Implementation of Image Filter widget",
implementation: ImageFilterImplementation(),
description: ImageFilterDescription(),
link: "https://api.flutter.dev/flutter/widgets/ImageFiltered-class.html",
category: [WidgetCategoy.Assets, WidgetCategoy.Basics],
codeString: ImageFilterCode()),
WidgetModel(
name: "Outlined Button",
implementation: OutlinedButtonImplimentation(),
Expand Down Expand Up @@ -366,6 +358,14 @@ const List<WidgetModel> widgets = [
link: "https://api.flutter.dev/flutter/widgets/Wrap-class.html",
category: [WidgetCategoy.Layout],
codeString: WrapCode()),
WidgetModel(
name: "SwitchList Tile ",
subtitle: "SwitchList Tile Widget",
implementation: SwitchListTileWidget(),
description: SwitchListTileDescription(),
link: "https://api.flutter.dev/flutter/material/SwitchListTile-class.html",
category: [WidgetCategoy.Layout],
codeString:SwitchListTileCode()),
WidgetModel(
name: "Hero",
subtitle: "Hero Animation between widgets",
Expand Down Expand Up @@ -1057,3 +1057,5 @@ const List<WidgetModel> widgets = [
codeString: AnimatedPositionedCode(),
),
];