Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commit 3f8281a

Browse files
author
Madda, Shylendra
committed
Add bottom nav in home with widgets and samples, Add share and app info
1 parent 9f555fd commit 3f8281a

26 files changed

+930
-82
lines changed

‎lib/code.dart‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
import 'package:flutter/material.dart';
22

3-
import 'home.dart';
3+
import 'main/home.dart';
44

55
class CodeWidget extends StatelessWidget {
66
final Sample sample;

‎lib/main/appinfo.dart‎

Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,26 @@
1+
import 'package:flutter/material.dart';
2+
3+
class AppInfoScreen extends StatelessWidget {
4+
@override
5+
Widget build(BuildContext context) {
6+
return Scaffold(
7+
appBar: AppBar(title: Text("Flutter Samples - App Info")),
8+
body: Container(
9+
color: Colors.blue,
10+
child: ListView(
11+
padding: const EdgeInsets.all(30),
12+
children: <Widget>[
13+
Image.asset('assets/images/flutter_icon.png',
14+
width: 150, height: 80),
15+
Text('Flutter Samples \nVersion 1.0.1',
16+
style: TextStyle(fontWeight: FontWeight.bold, fontSize: 20)),
17+
Padding(
18+
padding: const EdgeInsets.fromLTRB(0, 10, 0, 0),
19+
child: Text(
20+
('This app is basically to learn Flutter Widgets and Samples with souce code. More samples will be updated.')),
21+
)
22+
],
23+
),
24+
));
25+
}
26+
}

‎lib/main/home.dart‎

Lines changed: 110 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,110 @@
1+
import 'package:FlutterSamples/samples.dart';
2+
import 'package:FlutterSamples/widgets.dart';
3+
import 'package:flutter/material.dart';
4+
import 'package:share/share.dart';
5+
6+
import 'appinfo.dart';
7+
8+
class HomeScreen extends StatefulWidget {
9+
@override
10+
HomeScreenState createState() => HomeScreenState();
11+
}
12+
13+
class HomeScreenState extends State<HomeScreen> {
14+
var _selectedIndex = 0;
15+
final List<Widget> _widgetOptions = [WidgetsScreen(), SamplesScreen()];
16+
17+
@override
18+
Widget build(BuildContext context) {
19+
return WillPopScope(
20+
onWillPop: onBackPressed,
21+
child: new Scaffold(
22+
appBar: new AppBar(
23+
title: new Text('Flutter Samples'),
24+
actions: <Widget>[
25+
IconButton(
26+
icon: const Icon(Icons.share),
27+
color: Colors.white,
28+
tooltip: 'Share app',
29+
onPressed: () {
30+
Share.share(
31+
'Check out my app Flutter Samples at https://play.google.com/store/apps/details?id=com.geeklabs.fluttersamples');
32+
},
33+
),
34+
IconButton(
35+
icon: const Icon(Icons.announcement),
36+
color: Colors.white,
37+
tooltip: 'App Info',
38+
onPressed: () {
39+
Navigator.push(
40+
context,
41+
MaterialPageRoute(builder: (context) => AppInfoScreen()),
42+
);
43+
},
44+
),
45+
],
46+
),
47+
body: Center(
48+
child: _widgetOptions.elementAt(_selectedIndex),
49+
),
50+
bottomNavigationBar: BottomNavigationBar(
51+
items: const <BottomNavigationBarItem>[
52+
BottomNavigationBarItem(
53+
icon: Icon(Icons.widgets),
54+
title: Text('Widgets'),
55+
),
56+
BottomNavigationBarItem(
57+
icon: Icon(Icons.desktop_mac),
58+
title: Text('Samples'),
59+
)
60+
],
61+
currentIndex: _selectedIndex,
62+
selectedItemColor: Colors.amber[800],
63+
onTap: onItemTapped,
64+
),
65+
));
66+
}
67+
68+
Future<bool> onBackPressed() {
69+
if (_selectedIndex == 1) {
70+
onItemTapped(0);
71+
return Future.value(false);
72+
} else {
73+
return showDialog(
74+
context: context,
75+
builder: (context) => AlertDialog(
76+
title: Text('Are you sure?'),
77+
content: Text('Do you want to exit an App'),
78+
actions: <Widget>[
79+
GestureDetector(
80+
child: FlatButton(
81+
child: Text("No"),
82+
onPressed: () => Navigator.of(context).pop(false)),
83+
),
84+
SizedBox(height: 16),
85+
GestureDetector(
86+
child: FlatButton(
87+
child: Text("YES", style: TextStyle(color: Colors.grey)),
88+
onPressed: () => Navigator.of(context).pop(true)),
89+
),
90+
],
91+
),
92+
) ??
93+
Future.value(false);
94+
}
95+
}
96+
97+
void onItemTapped(int index) {
98+
setState(() {
99+
_selectedIndex = index;
100+
});
101+
}
102+
}
103+
104+
class Sample {
105+
final int id;
106+
final String title;
107+
final String sourceCode;
108+
109+
Sample(this.id, this.title, this.sourceCode);
110+
}

‎lib/main.dart‎ renamed to ‎lib/main/main.dart‎

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -3,15 +3,13 @@ import 'dart:async';
33
import 'package:flutter/material.dart';
44

55
import 'home.dart';
6-
import 'login.dart';
76

87
void main() {
98
runApp(MaterialApp(
109
home: SplashScreen(),
1110
routes: <String, WidgetBuilder>{
1211
'/HomeScreen': (BuildContext context) => HomeScreen(),
13-
'/SplashScreen': (BuildContext context) => SplashScreen(),
14-
'/LoginScreen': (BuildContext context) => LoginScreen()
12+
'/SplashScreen': (BuildContext context) => SplashScreen()
1513
},
1614
));
1715
}
@@ -47,4 +45,3 @@ class SplashScreenState extends State<SplashScreen> {
4745
);
4846
}
4947
}
50-
// Release version 1.0.0 in play store

‎lib/output.dart‎

Lines changed: 47 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -1,16 +1,22 @@
1-
import 'package:FlutterSamples/appbar.dart';
2-
import 'package:FlutterSamples/drawer.dart';
3-
import 'package:FlutterSamples/gallary.dart';
4-
import 'package:FlutterSamples/silverappbar.dart';
5-
import 'package:FlutterSamples/splash.dart';
6-
import 'package:FlutterSamples/tabbar.dart';
7-
import 'package:FlutterSamples/todo.dart';
1+
import 'package:FlutterSamples/samples/appbar.dart';
2+
import 'package:FlutterSamples/samples/drawer.dart';
3+
import 'package:FlutterSamples/samples/gallary.dart';
4+
import 'package:FlutterSamples/samples/homesample.dart';
5+
import 'package:FlutterSamples/samples/silverappbar.dart';
6+
import 'package:FlutterSamples/samples/splash.dart';
7+
import 'package:FlutterSamples/samples/tabbar.dart';
8+
import 'package:FlutterSamples/samples/todo.dart';
9+
import 'package:FlutterSamples/widgets/buttons.dart';
10+
import 'package:FlutterSamples/widgets/checkbox.dart';
11+
import 'package:FlutterSamples/widgets/dropdown.dart';
12+
import 'package:FlutterSamples/widgets/popupmenu.dart';
13+
import 'package:FlutterSamples/widgets/snackbar.dart';
14+
import 'package:FlutterSamples/widgets/text.dart';
815
import 'package:flutter/material.dart';
916

10-
import 'bottomnav.dart';
11-
import 'home.dart';
12-
import 'homesample.dart';
13-
import 'login.dart';
17+
import 'main/home.dart';
18+
import 'samples/bottomnav.dart';
19+
import 'samples/login.dart';
1420

1521
class OutputWidget extends StatefulWidget {
1622
final Sample sample;
@@ -87,6 +93,36 @@ class OutputState extends State<OutputWidget> {
8793
screenName = TabBarClass();
8894
}
8995
break;
96+
case 11:
97+
{
98+
screenName = ButtonsScreen();
99+
}
100+
break;
101+
case 12:
102+
{
103+
screenName = DropDownScreen();
104+
}
105+
break;
106+
case 13:
107+
{
108+
screenName = PopupMenuScreen();
109+
}
110+
break;
111+
case 14:
112+
{
113+
screenName = SnackBarScreen();
114+
}
115+
break;
116+
case 15:
117+
{
118+
screenName = TextScreen();
119+
}
120+
break;
121+
case 16:
122+
{
123+
screenName = CheckBoxScreen();
124+
}
125+
break;
90126
}
91127
return screenName;
92128
}

‎lib/sample.dart‎ renamed to ‎lib/samplepreview.dart‎

Lines changed: 8 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,23 +1,24 @@
1-
import 'package:flutter/material.dart';
21
import 'package:FlutterSamples/code.dart';
32
import 'package:FlutterSamples/output.dart';
3+
import 'package:flutter/material.dart';
44

5-
import 'home.dart';
5+
import 'main/home.dart';
66

7-
class SampleScreen extends StatefulWidget {
7+
// ignore: must_be_immutable
8+
class SamplePreviewScreen extends StatefulWidget {
89
final Sample sample;
910
int selectedIndex = 0;
1011
TextStyle optionStyle = TextStyle(fontSize: 30, fontWeight: FontWeight.bold);
1112

12-
SampleScreen({Key key, @required this.sample}) : super(key: key);
13+
SamplePreviewScreen({Key key, @required this.sample}) : super(key: key);
1314

1415
@override
15-
State<SampleScreen> createState() {
16-
return SampleScreenState();
16+
State<SamplePreviewScreen> createState() {
17+
return SamplePreviewScreenState();
1718
}
1819
}
1920

20-
class SampleScreenState extends State<SampleScreen> {
21+
class SamplePreviewScreenState extends State<SamplePreviewScreen> {
2122
int currentIndex = 0;
2223

2324
@override

‎lib/home.dart‎ renamed to ‎lib/samples.dart‎

Lines changed: 21 additions & 57 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,14 @@
1-
import 'package:FlutterSamples/sample.dart';
1+
import 'package:FlutterSamples/samplepreview.dart';
22
import 'package:flutter/material.dart';
33

4-
class HomeScreen extends StatefulWidget {
4+
import 'main/home.dart';
5+
6+
class SamplesScreen extends StatefulWidget {
57
@override
6-
HomeScreenState createState() => newHomeScreenState();
8+
SamplesState createState() => SamplesState();
79
}
810

9-
class HomeScreenState extends State<HomeScreen> {
11+
class SamplesState extends State<SamplesScreen> {
1012
List<Sample> sampleEntries = List();
1113

1214
@override
@@ -522,7 +524,7 @@ class AppBarScreen extends StatelessWidget {
522524
523525
"""));
524526

525-
sampleEntries.add(Sample(8, "BottomNavigation", """
527+
sampleEntries.add(Sample(8, "Bottom Navigation", """
526528
527529
import 'package:flutter/material.dart';
528530
@@ -554,7 +556,7 @@ class BottomNavState extends State<BottomNavigationScreen> {
554556
Widget build(BuildContext context) {
555557
return Scaffold(
556558
appBar: AppBar(
557-
title: const Text('BottomNavigationBar Sample'),
559+
title: const Text('BottomNavigation Demo'),
558560
),
559561
body: Center(
560562
child: _widgetOptions.elementAt(_selectedIndex),
@@ -682,63 +684,25 @@ class TabBarClass extends StatelessWidget {
682684
683685
"""));
684686

685-
return WillPopScope(
686-
onWillPop: onBackPressed,
687-
child: new Scaffold(
688-
appBar: new AppBar(
689-
title: new Text('Flutter Samples'),
690-
),
691-
body: ListView.builder(
692-
padding: const EdgeInsets.all(8),
693-
itemCount: sampleEntries.length,
694-
itemBuilder: (BuildContext context, int index) {
695-
return Card(
696-
child: ListTile(
697-
title: Text('${sampleEntries[index].title}'),
698-
// subtitle: Text('Sub title'),
699-
trailing: Icon(Icons.arrow_forward_ios),
700-
onTap: () => onTapped(index, context),
701-
));
702-
})));
687+
return Scaffold(
688+
body: ListView.builder(
689+
padding: const EdgeInsets.all(8),
690+
itemCount: sampleEntries.length,
691+
itemBuilder: (BuildContext context, int index) {
692+
return Card(
693+
child: ListTile(
694+
title: Text('${sampleEntries[index].title}'),
695+
trailing: Icon(Icons.arrow_forward_ios),
696+
onTap: () => onTapped(index, context),
697+
));
698+
}));
703699
}
704700

705701
onTapped(int index, BuildContext context) {
706702
Navigator.push(
707703
context,
708704
MaterialPageRoute(
709-
builder: (context) => SampleScreen(sample: sampleEntries[index])),
705+
builder: (context) => SamplePreviewScreen(sample: sampleEntries[index])),
710706
);
711707
}
712-
713-
Future<bool> onBackPressed() {
714-
return showDialog(
715-
context: context,
716-
builder: (context) => AlertDialog(
717-
title: Text('Are you sure?'),
718-
content: Text('Do you want to exit an App'),
719-
actions: <Widget>[
720-
GestureDetector(
721-
child: FlatButton(
722-
child: Text("No"),
723-
onPressed: () => Navigator.of(context).pop(false)),
724-
),
725-
SizedBox(height: 16),
726-
GestureDetector(
727-
child: FlatButton(
728-
child: Text("YES", style: TextStyle(color: Colors.grey)),
729-
onPressed: () => Navigator.of(context).pop(true)),
730-
),
731-
],
732-
),
733-
) ??
734-
false;
735-
}
736-
}
737-
738-
class Sample {
739-
final int id;
740-
final String title;
741-
final String sourceCode;
742-
743-
Sample(this.id, this.title, this.sourceCode);
744708
}
File renamed without changes.

‎lib/bottomnav.dart‎ renamed to ‎lib/samples/bottomnav.dart‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ class BottomNavigationScreen extends StatefulWidget {
66
}
77

88
class BottomNavState extends State<BottomNavigationScreen> {
9-
int _selectedIndex = 0;
9+
var _selectedIndex = 0;
1010
static const TextStyle optionStyle =
1111
TextStyle(fontSize: 30, fontWeight: FontWeight.bold);
1212
static const List<Widget> _widgetOptions = <Widget>[
File renamed without changes.

0 commit comments

Comments
(0)

AltStyle によって変換されたページ (->オリジナル) /