repo_id
stringlengths 21
168
| file_path
stringlengths 36
210
| content
stringlengths 1
9.98M
| __index_level_0__
int64 0
0
|
---|---|---|---|
mirrored_repositories/FlutterWidgetsSnippets/lib | mirrored_repositories/FlutterWidgetsSnippets/lib/widgets/banner.dart | import 'package:flutter/material.dart';
class BannerWidget extends StatelessWidget {
const BannerWidget({super.key});
@override
Widget build(BuildContext context) {
return Scaffold(
appBar: AppBar(
title: const Text("Banner"),
),
body: Center(
child: Container(
margin: const EdgeInsets.all(10.0),
child: ClipRect(
child: Banner(
location: BannerLocation.topEnd,
message: "25% Off",
child: Container(
color: Colors.grey,
child: Padding(
padding: const EdgeInsets.fromLTRB(10, 20, 10, 20),
child: Column(
mainAxisSize: MainAxisSize.min,
children: [
Image.network(
"https://docs.flutter.dev/assets/images/shared/brand/flutter/logo/flutter-lockup.png"),
Row(
mainAxisAlignment: MainAxisAlignment.spaceBetween,
children: [
const Text(
'Get your laptop servicing Now!',
style: TextStyle(
fontSize: 17,
fontWeight: FontWeight.bold),
),
ElevatedButton(
onPressed: () {},
child: const Text('Register Now'))
],
)
],
),
)),
),
)),
));
}
}
| 0 |
mirrored_repositories/FlutterWidgetsSnippets/lib | mirrored_repositories/FlutterWidgetsSnippets/lib/widgets/widgets.dart | export 'calender.dart';
export 'floatingactionbar.dart';
export 'glasseffect.dart';
export 'searchbar.dart';
export 'aboutdialog.dart';
export 'aboutlisttile.dart';
export 'absorbpointer.dart';
export 'alertdialog.dart';
export 'animatedalign.dart';
export 'animatedbuilder.dart';
export 'animatedcontainer.dart';
export 'animatedcrossfade.dart';
export 'animatedicon.dart';
export 'animatedlist.dart';
export 'animatedmodalbarrier.dart';
export 'animatedopacity.dart';
export 'animatedpadding.dart';
export 'animatedphysicalmodel.dart';
export 'animatedposition.dart';
export 'animatedrotation.dart';
export 'animatedsize.dart';
export 'animateswitcher.dart';
export 'appbar.dart';
export 'aspectratio.dart';
export 'autocomplete.dart';
export 'backdropfilter.dart';
export 'banner.dart';
export 'baseline.dart';
export 'bottomnavigationbar.dart';
export 'modelbottomsheet.dart';
export 'builder.dart';
export 'card.dart';
export 'checkboxlisttile.dart';
export 'chip.dart';
export 'cupertinocontextmenu.dart';
export 'cupertinopicker.dart';
export 'custompaint.dart';
export 'customscrollview.dart';
export 'calender.dart';
export 'calender.dart';
export 'calender.dart';
export 'calender.dart';
export 'calender.dart';
export 'calender.dart';
export 'calender.dart';
export 'calender.dart';
export 'calender.dart';
export 'calender.dart';
export 'calender.dart';
export 'calender.dart';
export 'calender.dart';
export 'calender.dart';
export 'calender.dart';
export 'calender.dart';
export 'calender.dart';
export 'calender.dart';
export 'calender.dart';
export 'calender.dart';
export 'calender.dart';
export 'calender.dart';
export 'calender.dart';
export 'calender.dart';
| 0 |
mirrored_repositories/FlutterWidgetsSnippets/lib | mirrored_repositories/FlutterWidgetsSnippets/lib/widgets/absorbpointer.dart | import 'package:flutter/material.dart';
class AbsorbPointerWidget extends StatelessWidget {
const AbsorbPointerWidget({super.key});
@override
Widget build(BuildContext context) {
return Scaffold(
appBar: AppBar(
title: const Text("AbsorbPointer"),
),
body: Center(
child: Stack(
alignment: AlignmentDirectional.center,
children: [
SizedBox(
width: 200.0,
height: 100.0,
child: ElevatedButton(
onPressed: () {},
child: null,
),
),
SizedBox(
width: 100.0,
height: 200.0,
child: AbsorbPointer(
child: ElevatedButton(
style: ElevatedButton.styleFrom(
backgroundColor: Colors.blue.shade200),
onPressed: () {},
child: null,
),
),
)
],
),
));
}
}
| 0 |
mirrored_repositories/FlutterWidgetsSnippets/lib | mirrored_repositories/FlutterWidgetsSnippets/lib/widgets/calender.dart | import 'package:flutter/material.dart';
import 'package:intl/intl.dart';
class CalenderWidget extends StatefulWidget {
const CalenderWidget({super.key});
@override
State<CalenderWidget> createState() => _CalenderWidgetState();
}
class _CalenderWidgetState extends State<CalenderWidget> {
DateTime _dispayDateTime = DateTime.now();
showCalender(BuildContext context) async {
DateTime? newDate = await showDatePicker(
context: context,
initialDate: DateTime.now(),
firstDate: DateTime(1800),
lastDate: DateTime(3000));
setState(() {
_dispayDateTime = newDate ?? DateTime.now();
});
}
String datetimeFormat(DateTime dateTime) {
// DateFormat.yMEd().format(_dateTime)
return DateFormat.yMEd().format(dateTime);
}
@override
Widget build(BuildContext context) {
return Scaffold(
appBar: AppBar(title: const Text("Calender Widget")),
body: Center(
child: Container(
padding: const EdgeInsets.all(10),
decoration: BoxDecoration(
borderRadius: BorderRadius.circular(25),
color: Colors.teal,
),
child: Row(
mainAxisSize: MainAxisSize.min,
mainAxisAlignment: MainAxisAlignment.center,
children: [
Text(
datetimeFormat(_dispayDateTime),
softWrap: false,
maxLines: 1,
overflow: TextOverflow.ellipsis,
style: const TextStyle(color: Colors.white),
),
Container(
margin: const EdgeInsets.only(left: 5),
decoration: const BoxDecoration(
color: Colors.white,
shape: BoxShape.circle,
),
child: IconButton(
icon: const Icon(Icons.event),
onPressed: () {
showCalender(context);
},
),
),
],
),
),
),
);
}
}
| 0 |
mirrored_repositories/FlutterWidgetsSnippets/lib | mirrored_repositories/FlutterWidgetsSnippets/lib/widgets/chip.dart | import 'package:flutter/material.dart';
import 'package:flutter/services.dart';
class ChipWidget extends StatefulWidget {
const ChipWidget({super.key});
@override
State<ChipWidget> createState() => _ChipWidgetState();
}
class _ChipWidgetState extends State<ChipWidget> {
bool isSelected = false;
@override
Widget build(BuildContext context) {
return Scaffold(
appBar: AppBar(
title: const Text("Chip"),
),
body: Center(
child: Column(
mainAxisSize: MainAxisSize.min,
children: [
Chip(
label: const Text('This is a Flutter Chip'),
onDeleted: () {
SystemChannels.textInput.invokeMethod('TextInput.hide');
ScaffoldMessenger.of(context).showSnackBar(const SnackBar(
content: Text('onDeleted'),
));
},
),
ChoiceChip(
label: const Text('Choice Chip'),
selected: isSelected,
selectedColor: Colors.orangeAccent,
onSelected: (value) {
setState(() {
isSelected = value;
});
},
)
],
),
));
}
}
| 0 |
mirrored_repositories/FlutterWidgetsSnippets/lib | mirrored_repositories/FlutterWidgetsSnippets/lib/widgets/animatedcontainer.dart | import 'package:flutter/material.dart';
class AnimatedContainerWidget extends StatefulWidget {
const AnimatedContainerWidget({super.key});
@override
State<AnimatedContainerWidget> createState() =>
_AnimatedContainerWidgetState();
}
class _AnimatedContainerWidgetState extends State<AnimatedContainerWidget>
with TickerProviderStateMixin {
bool selected = false;
@override
Widget build(BuildContext context) {
return Scaffold(
appBar: AppBar(title: const Text('Animated Builder')),
body: GestureDetector(
onTap: () {
setState(() {
selected = !selected;
});
},
child: Center(
child: AnimatedContainer(
width: selected ? 200 : 100,
height: selected ? 100 : 200,
color: selected ? Colors.blueGrey : Colors.white,
alignment: selected ? Alignment.center : Alignment.topCenter,
duration: const Duration(seconds: 2),
curve: Curves.fastOutSlowIn,
child: const Center(
child: FlutterLogo(
size: 150.0,
),
),
),
),
),
);
}
}
| 0 |
mirrored_repositories/FlutterWidgetsSnippets/lib | mirrored_repositories/FlutterWidgetsSnippets/lib/widgets/animatedbuilder.dart | import 'package:flutter/material.dart';
import 'dart:math' as math;
class AnimatedBuilderWidget extends StatefulWidget {
const AnimatedBuilderWidget({super.key});
@override
State<AnimatedBuilderWidget> createState() => _AnimatedBuilderWidgetState();
}
class _AnimatedBuilderWidgetState extends State<AnimatedBuilderWidget>
with TickerProviderStateMixin {
late final AnimationController _controller =
AnimationController(duration: const Duration(seconds: 10), vsync: this)
..repeat();
@override
void dispose() {
_controller.dispose();
super.dispose();
}
@override
Widget build(BuildContext context) {
return Scaffold(
appBar: AppBar(title: const Text('Animated Builder')),
body: Center(
child: AnimatedBuilder(
animation: _controller,
builder: (BuildContext context, Widget? child) {
return Transform.rotate(
angle: _controller.value * 2 * math.pi,
child: child,
);
},
child: const FlutterLogo(
size: 150.0,
),
),
),
);
}
}
| 0 |
mirrored_repositories/FlutterWidgetsSnippets/lib | mirrored_repositories/FlutterWidgetsSnippets/lib/widgets/customscrollview.dart | import 'package:flutter/material.dart';
class CustomScrollViewWidget extends StatelessWidget {
const CustomScrollViewWidget({super.key});
@override
Widget build(BuildContext context) {
return Scaffold(
appBar: AppBar(
title: const Text("CustomScrollView"),
),
body: CustomScrollView(
slivers: [
SliverGrid(
delegate: SliverChildBuilderDelegate(((context, index) {
var color = Colors.orange[100 * (index % 9)] ?? Colors.black;
return Container(
alignment: Alignment.center,
color: color,
child: Text(color.toHex().toUpperCase().toString()),
);
}), childCount: 50),
gridDelegate: const SliverGridDelegateWithMaxCrossAxisExtent(
maxCrossAxisExtent: 200.0,
crossAxisSpacing: 10.0,
mainAxisSpacing: 10.0,
childAspectRatio: 4.0))
],
));
}
}
extension HexColor on Color {
/// String is in the format "aabbcc" or "ffaabbcc" with an optional leading "#".
static Color fromHex(String hexString) {
final buffer = StringBuffer();
if (hexString.length == 6 || hexString.length == 7) buffer.write('ff');
buffer.write(hexString.replaceFirst('#', ''));
return Color(int.parse(buffer.toString(), radix: 16));
}
/// Prefixes a hash sign if [leadingHashSign] is set to `true` (default is `true`).
String toHex({bool leadingHashSign = true}) => '${leadingHashSign ? '#' : ''}'
'${red.toRadixString(16).padLeft(2, '0')}'
'${green.toRadixString(16).padLeft(2, '0')}'
'${blue.toRadixString(16).padLeft(2, '0')}'
'${alpha.toRadixString(16).padLeft(2, '0')}';
}
| 0 |
mirrored_repositories/FlutterWidgetsSnippets/lib | mirrored_repositories/FlutterWidgetsSnippets/lib/widgets/autocomplete.dart | import 'package:flutter/material.dart';
import 'package:flutter/services.dart';
class AutoCompleteWidget extends StatelessWidget {
const AutoCompleteWidget({super.key});
static const List<String> fruits = ['apple', 'banana', 'melon'];
@override
Widget build(BuildContext context) {
return Scaffold(
appBar: AppBar(
title: const Text("AutoComplete"),
),
body: Autocomplete<String>(
optionsBuilder: (textEditingValue) {
if (textEditingValue.toString() == '') {
return const Iterable<String>.empty();
}
return fruits.where((element) {
return element.contains(textEditingValue.text.toLowerCase());
});
},
onSelected: (option) {
SystemChannels.textInput.invokeMethod('TextInput.hide');
ScaffoldMessenger.of(context).showSnackBar(SnackBar(
content: Text('The $option was selected'),
));
},
));
}
void showInSnackBar(String value) {}
}
| 0 |
mirrored_repositories/FlutterWidgetsSnippets/lib | mirrored_repositories/FlutterWidgetsSnippets/lib/widgets/animatedlist.dart | import 'package:flutter/material.dart';
class AnimatedListWidget extends StatefulWidget {
const AnimatedListWidget({super.key});
@override
State<AnimatedListWidget> createState() => _AnimatedListWidgetState();
}
class _AnimatedListWidgetState extends State<AnimatedListWidget>
with TickerProviderStateMixin {
final _items = [];
final GlobalKey<AnimatedListState> _key = GlobalKey();
void _addItem() {
_items.insert(0, "item ${_items.length + 1}");
_key.currentState!.insertItem(0, duration: const Duration(seconds: 1));
}
void _removeItem(int index) {
_key.currentState!.removeItem(index,
duration: const Duration(milliseconds: 300), (_, animation) {
return SizeTransition(
sizeFactor: animation,
child: const Card(
margin: EdgeInsets.all(10),
color: Colors.red,
child: ListTile(
title: Text('Deleted', style: TextStyle(fontSize: 24)),
)),
);
});
_items.removeAt(index);
}
@override
Widget build(BuildContext context) {
return Scaffold(
appBar: AppBar(
title: const Text("Widget Name"),
),
body: Column(
children: [
const SizedBox(
height: 10,
),
IconButton(
onPressed: _addItem,
icon: const Icon(Icons.add),
),
Expanded(
child: AnimatedList(
key: _key,
initialItemCount: 0,
padding: const EdgeInsets.all(0),
itemBuilder: ((context, index, animation) {
return SizeTransition(
sizeFactor: animation,
key: UniqueKey(),
child: Card(
margin: const EdgeInsets.all(10),
color: Colors.orange,
child: ListTile(
title: Text(
_items[index],
style: const TextStyle(fontSize: 24),
),
trailing: IconButton(
onPressed: (() {
_removeItem(index);
}),
icon: const Icon(Icons.delete)),
),
),
);
}),
))
],
),
);
}
}
| 0 |
mirrored_repositories/FlutterWidgetsSnippets/lib | mirrored_repositories/FlutterWidgetsSnippets/lib/widgets/animatedmodalbarrier.dart | import 'package:flutter/material.dart';
class AnimatedModalBarrierWidget extends StatefulWidget {
const AnimatedModalBarrierWidget({super.key});
@override
State<AnimatedModalBarrierWidget> createState() =>
_AnimatedModalBarrierWidgetState();
}
class _AnimatedModalBarrierWidgetState extends State<AnimatedModalBarrierWidget>
with SingleTickerProviderStateMixin {
bool _isPressed = false;
late Widget _animatedModelBarrier;
late AnimationController _controller;
late Animation<Color?> _colorAnimation;
@override
void initState() {
ColorTween colorTween = ColorTween(
begin: Colors.orange.withOpacity(0.5),
end: Colors.blueGrey.withOpacity(0.5));
_controller =
AnimationController(vsync: this, duration: const Duration(seconds: 3));
_colorAnimation = colorTween.animate(_controller);
_animatedModelBarrier = AnimatedModalBarrier(
color: _colorAnimation,
dismissible: true,
);
super.initState();
}
@override
Widget build(BuildContext context) {
return Scaffold(
appBar: AppBar(
title: const Text("AnimatedModalbarrier"),
),
body: Center(
child: Padding(
padding: const EdgeInsets.all(15.0),
child: Column(
mainAxisAlignment: MainAxisAlignment.center,
children: <Widget>[
SizedBox(
width: 250,
height: 100,
child: Stack(
alignment: AlignmentDirectional.center,
children: [
ElevatedButton(
style: ElevatedButton.styleFrom(
backgroundColor: Colors.orangeAccent),
onPressed: () {
setState(() {
_isPressed = true;
});
_controller.reset();
_controller.forward();
Future.delayed(const Duration(seconds: 3), (() {
setState(() {
_isPressed = false;
});
}));
},
child: const Text('Press'),
),
if (_isPressed) _animatedModelBarrier
],
),
)
],
),
),
),
);
}
}
| 0 |
mirrored_repositories/FlutterWidgetsSnippets/lib | mirrored_repositories/FlutterWidgetsSnippets/lib/widgets/animatedrotation.dart | import 'package:flutter/material.dart';
class AnimatedRotationWidget extends StatefulWidget {
const AnimatedRotationWidget({super.key});
@override
State<AnimatedRotationWidget> createState() => _AnimatedRotationWidgetState();
}
class _AnimatedRotationWidgetState extends State<AnimatedRotationWidget> {
double turn = 0;
@override
Widget build(BuildContext context) {
return Scaffold(
appBar: AppBar(
title: const Text("Widget Name"),
),
body: Center(
child: Column(mainAxisAlignment: MainAxisAlignment.center, children: [
AnimatedRotation(
turns: turn,
duration: const Duration(seconds: 1),
child: const FlutterLogo(
size: 100,
),
),
ElevatedButton(
onPressed: () {
setState(() {
turn += 1 / 4;
});
},
child: const Text("Rotate Logo"))
]),
),
);
}
}
| 0 |
mirrored_repositories/FlutterWidgetsSnippets/lib | mirrored_repositories/FlutterWidgetsSnippets/lib/widgets/backdropfilter.dart | import 'dart:ui';
import 'package:flutter/material.dart';
class BackdropFilterWidget extends StatelessWidget {
const BackdropFilterWidget({super.key});
@override
Widget build(BuildContext context) {
return Scaffold(
appBar: AppBar(
title: const Text("BackdropFilter"),
),
body: Stack(
children: [
Text(
'0' * 10000,
style: const TextStyle(color: Colors.green),
),
Center(
child: ClipRect(
child: BackdropFilter(
filter: ImageFilter.blur(sigmaX: 4.0, sigmaY: 4.0),
child: Container(
alignment: Alignment.center,
width: 250,
height: 250,
child: const Text('Blur'),
),
)),
)
],
));
}
}
| 0 |
mirrored_repositories/FlutterWidgetsSnippets/lib | mirrored_repositories/FlutterWidgetsSnippets/lib/widgets/animatedsize.dart | import 'package:flutter/material.dart';
class AnimatedSizeWidget extends StatefulWidget {
const AnimatedSizeWidget({super.key});
@override
State<AnimatedSizeWidget> createState() => _AnimatedSizeWidgetState();
}
class _AnimatedSizeWidgetState extends State<AnimatedSizeWidget> {
double _size = 300;
@override
Widget build(BuildContext context) {
return Scaffold(
appBar: AppBar(
title: const Text("AnimatedSize"),
),
body: Center(
child: GestureDetector(
onTap: () {
setState(() {
_size = _size == 300 ? 100 : 300;
});
},
child: Container(
color: Colors.white,
child: AnimatedSize(
duration: const Duration(seconds: 1),
curve: Curves.easeIn,
child: FlutterLogo(size: _size),
),
),
),
),
);
}
}
| 0 |
mirrored_repositories/FlutterWidgetsSnippets/lib | mirrored_repositories/FlutterWidgetsSnippets/lib/widgets/animatedicon.dart | import 'package:flutter/material.dart';
class AnimatedIconWidget extends StatefulWidget {
const AnimatedIconWidget({super.key});
@override
State<AnimatedIconWidget> createState() => _AnimatedIconWidgetState();
}
class _AnimatedIconWidgetState extends State<AnimatedIconWidget>
with TickerProviderStateMixin {
bool _isPlaying = false;
late AnimationController _controller;
@override
void initState() {
_controller =
AnimationController(vsync: this, duration: const Duration(seconds: 1));
super.initState();
}
@override
void dispose() {
_controller.dispose();
super.dispose();
}
@override
Widget build(BuildContext context) {
return Scaffold(
appBar: AppBar(
title: const Text("Widget Name"),
),
body: Center(
child: GestureDetector(
onTap: (() {
if (_isPlaying == false) {
_controller.forward();
_isPlaying = true;
} else {
_controller.reverse();
_isPlaying = false;
}
}),
child: AnimatedIcon(
icon: AnimatedIcons.play_pause,
progress: _controller,
size: 100,
),
),
));
}
}
| 0 |
mirrored_repositories/FlutterWidgetsSnippets/lib | mirrored_repositories/FlutterWidgetsSnippets/lib/widgets/aspectratio.dart | import 'package:flutter/material.dart';
class AspectRatioWidget extends StatelessWidget {
const AspectRatioWidget({super.key});
@override
Widget build(BuildContext context) {
return Scaffold(
appBar: AppBar(
title: const Text("AspectRatio"),
),
body: Container(
color: Colors.orange,
alignment: Alignment.center,
width: double.infinity,
height: 300,
child: AspectRatio(
aspectRatio: 16 / 9,
child: Container(
color: Colors.blueGrey,
),
),
));
}
}
| 0 |
mirrored_repositories/FlutterWidgetsSnippets/lib | mirrored_repositories/FlutterWidgetsSnippets/lib/widgets/animatedphysicalmodel.dart | import 'package:flutter/material.dart';
import 'package:widgetssamples/utils/app_theme.dart';
class AnimatedPhysicalModelWidget extends StatefulWidget {
const AnimatedPhysicalModelWidget({super.key});
@override
State<AnimatedPhysicalModelWidget> createState() =>
_AnimatedPhysicalModelWidgetState();
}
class _AnimatedPhysicalModelWidgetState
extends State<AnimatedPhysicalModelWidget> {
bool _isFlat = true;
@override
Widget build(BuildContext context) {
return Scaffold(
appBar: AppBar(
title: const Text("AnimatedPhysicalModel"),
),
body: Center(
child: Column(
mainAxisAlignment: MainAxisAlignment.center,
crossAxisAlignment: CrossAxisAlignment.center,
children: [
AnimatedPhysicalModel(
shape: BoxShape.rectangle,
elevation: _isFlat ? 0 : 6.0,
color: ThemeConfig.darkBG,
shadowColor: Colors.white,
duration: const Duration(milliseconds: 500),
curve: Curves.fastOutSlowIn,
child: const SizedBox(
width: 120,
height: 120,
child: Icon(Icons.android_outlined),
),
),
const SizedBox(
height: 20,
),
ElevatedButton(
onPressed: () {
setState(() {
_isFlat = !_isFlat;
});
},
child: const Text('Click'),
)
],
),
));
}
}
| 0 |
mirrored_repositories/FlutterWidgetsSnippets/lib | mirrored_repositories/FlutterWidgetsSnippets/lib/widgets/alertdialog.dart | import 'package:flutter/material.dart';
class AlertDialogWidget extends StatelessWidget {
const AlertDialogWidget({super.key});
@override
Widget build(BuildContext context) {
return Scaffold(
appBar: AppBar(
title: const Text("AlertDialog "),
),
body: Center(
child: TextButton(
onPressed: () {
showDialog(
context: context,
builder: (context) => AlertDialog(
actions: [
TextButton(
onPressed: () {
Navigator.of(context).pop();
},
child: const Text('Close'))
],
title: const Text('Flutter Alert Dialog Widget'),
contentPadding: const EdgeInsets.all(20.0),
content: const Text('This is the Alert Dialog'),
),
);
},
child: const Text('Show Alert Dialog'),
),
));
}
}
| 0 |
mirrored_repositories/FlutterWidgetsSnippets/lib | mirrored_repositories/FlutterWidgetsSnippets/lib/widgets/animatedpadding.dart | import 'package:flutter/material.dart';
class AnimatedPaddingWidget extends StatefulWidget {
const AnimatedPaddingWidget({super.key});
@override
State<AnimatedPaddingWidget> createState() => _AnimatedPaddingWidgetState();
}
class _AnimatedPaddingWidgetState extends State<AnimatedPaddingWidget> {
double padValue = 0;
@override
Widget build(BuildContext context) {
return Scaffold(
appBar: AppBar(
title: const Text("AnimatedPadding"),
),
body: Center(
child: Column(mainAxisAlignment: MainAxisAlignment.center, children: [
ElevatedButton(
onPressed: () {
setState(() {
padValue = padValue == 0.0 ? 100.0 : 0.0;
});
},
style: ElevatedButton.styleFrom(backgroundColor: Colors.orange),
child: const Text('Change Padding'),
),
Text('Padding = $padValue'),
AnimatedPadding(
duration: const Duration(seconds: 2),
padding: EdgeInsets.all(padValue),
curve: Curves.easeInOut,
child: Container(
width: MediaQuery.of(context).size.width,
height: MediaQuery.of(context).size.height / 4,
color: Colors.orangeAccent,
),
)
]),
));
}
}
| 0 |
mirrored_repositories/FlutterWidgetsSnippets/lib | mirrored_repositories/FlutterWidgetsSnippets/lib/widgets/builder.dart | import 'package:flutter/material.dart';
class BuilderWidget extends StatelessWidget {
const BuilderWidget({super.key});
@override
Widget build(BuildContext context) {
return Scaffold(
appBar: AppBar(
title: const Text("Builder"),
),
body: myWidget());
}
//Builder will give access to a new context
myWidget() => Builder(builder: (context) {
return Text(
'Text with Theme',
style: Theme.of(context).textTheme.displayLarge,
);
});
}
| 0 |
mirrored_repositories/FlutterWidgetsSnippets/lib | mirrored_repositories/FlutterWidgetsSnippets/lib/widgets/animateswitcher.dart | import 'package:flutter/material.dart';
class AnimatedSwitcherWidget extends StatefulWidget {
const AnimatedSwitcherWidget({super.key});
@override
State<AnimatedSwitcherWidget> createState() => _AnimatedSwitcherWidgetState();
}
class _AnimatedSwitcherWidgetState extends State<AnimatedSwitcherWidget> {
int _count = 0;
@override
Widget build(BuildContext context) {
return Scaffold(
appBar: AppBar(
title: const Text("AnimatedSwitcher"),
),
body: Center(
child: Column(
mainAxisAlignment: MainAxisAlignment.center,
children: [
AnimatedSwitcher(
duration: const Duration(seconds: 1),
child: Text(
'$_count',
style: const TextStyle(fontSize: 40),
key: ValueKey(
_count), //key to track how the AnimatedSwitcher performs
),
transitionBuilder: (child, animation) {
return ScaleTransition(
scale: animation,
child: child,
);
},
),
ElevatedButton(
onPressed: () {
setState(() {
_count += 1;
});
},
child: const Text('Add'))
],
),
),
);
}
}
| 0 |
mirrored_repositories/FlutterWidgetsSnippets/lib | mirrored_repositories/FlutterWidgetsSnippets/lib/utils/app_theme.dart | import 'package:flutter/material.dart';
import 'package:flutter/services.dart';
class ThemeConfig {
// Color for Theme dark
static const Color darkTextColorPrimary = Color(0xFFFAFAFA);
static const Color darkTextColorSecondary = Color(0xFFF5F5F5);
static const Color darkPrimary = Color.fromRGBO(250, 250, 250, 1);
static const Color darkHintColor = Color.fromRGBO(158, 158, 166, 1);
static const Color darkSecondary = Color.fromRGBO(33, 150, 243, 1);
static const Color darkBG = Color(0xFF181A1B);
static ThemeData darkTheme = ThemeData(
colorScheme: const ColorScheme.dark(
primary: darkPrimary,
onPrimary: darkTextColorPrimary,
secondary: darkSecondary,
onSecondary: darkTextColorSecondary,
),
appBarTheme: const AppBarTheme(
color: Color(0xF023292C),
systemOverlayStyle: SystemUiOverlayStyle(
systemNavigationBarColor: Color(0xF023292C))),
scaffoldBackgroundColor: darkBG,
elevatedButtonTheme: ElevatedButtonThemeData(
style: ElevatedButton.styleFrom(
foregroundColor: Colors.white, backgroundColor: Colors.teal)),
textButtonTheme: TextButtonThemeData(
style: TextButton.styleFrom(
foregroundColor: Colors.white,
backgroundColor: Colors.teal,
disabledForegroundColor: Colors.grey.withOpacity(0.38),
)));
}
| 0 |
mirrored_repositories/FlutterWidgetsSnippets/lib | mirrored_repositories/FlutterWidgetsSnippets/lib/utils/navigate.dart | import 'package:flutter/material.dart';
class Navigate {
static Future pushPage(BuildContext context, Widget page) {
var val = Navigator.push(
context,
MaterialPageRoute(
builder: (BuildContext context) {
return page;
},
),
);
return val;
}
}
| 0 |
mirrored_repositories/FlutterWidgetsSnippets/lib | mirrored_repositories/FlutterWidgetsSnippets/lib/utils/custom_divider.dart | import 'package:flutter/material.dart';
class CustomDivider extends StatelessWidget {
const CustomDivider({super.key, required this.heading});
final String heading;
@override
Widget build(BuildContext context) {
return Row(
mainAxisAlignment: MainAxisAlignment.center,
children: [
Container(
padding: const EdgeInsets.only(left: 30, right: 0),
child: Text(heading,
style: const TextStyle(
color: Colors.grey,
)),
),
],
);
}
}
| 0 |
mirrored_repositories/FlutterWidgetsSnippets/lib | mirrored_repositories/FlutterWidgetsSnippets/lib/utils/utils.dart | export 'navigate.dart';
export 'app_theme.dart';
export 'custom_divider.dart';
export 'custom_search.dart';
| 0 |
mirrored_repositories/FlutterWidgetsSnippets/lib | mirrored_repositories/FlutterWidgetsSnippets/lib/utils/custom_search.dart | import 'package:flutter/material.dart';
import 'package:widgetssamples/utils/navigate.dart';
class CustomSearchDelegate extends SearchDelegate {
CustomSearchDelegate(this.widgetList);
List<Widget> widgetList;
// clear the search text
@override
List<Widget>? buildActions(BuildContext context) {
return [
IconButton(
onPressed: () {
query = '';
},
icon: const Icon(Icons.clear),
),
];
}
// second overwrite to pop out of search menu
@override
Widget? buildLeading(BuildContext context) {
return IconButton(
onPressed: () {
close(context, null);
},
icon: const Icon(Icons.arrow_back),
);
}
// third overwrite to show query result
@override
Widget buildResults(BuildContext context) {
List<Widget> matchQuery = [];
for (var widget in widgetList) {
if (widget.toString().toLowerCase().contains(query.toLowerCase())) {
matchQuery.add(widget);
}
}
return ListView.builder(
itemCount: matchQuery.length,
padding: const EdgeInsets.only(left: 10),
shrinkWrap: true,
itemBuilder: (context, index) {
Widget widget = matchQuery[index];
return ListTile(
dense: true,
contentPadding: const EdgeInsets.all(0),
leading: Text(
(index + 1).toString(),
style: const TextStyle(color: Colors.grey),
),
title: Text(
widget.toString(),
style: const TextStyle(fontSize: 15),
),
trailing: IconButton(
onPressed: () {
Navigate.pushPage(context, widget);
},
icon: const Icon(
Icons.arrow_forward_ios,
size: 15,
color: Colors.grey,
)),
);
},
);
}
// last overwrite to show the
// querying process at the runtime
@override
Widget buildSuggestions(BuildContext context) {
List<Widget> matchQuery = [];
for (var widget in widgetList) {
if (widget.toString().toLowerCase().contains(query.toLowerCase())) {
matchQuery.add(widget);
}
}
return ListView.builder(
itemCount: matchQuery.length,
padding: const EdgeInsets.only(left: 10),
shrinkWrap: true,
itemBuilder: (context, index) {
Widget widget = matchQuery[index];
return ListTile(
dense: true,
contentPadding: const EdgeInsets.all(0),
leading: Text(
(index + 1).toString(),
style: const TextStyle(color: Colors.grey),
),
title: Text(
widget.toString(),
style: const TextStyle(fontSize: 15),
),
trailing: IconButton(
onPressed: () {
Navigate.pushPage(context, widget);
},
icon: const Icon(
Icons.arrow_forward_ios,
size: 15,
color: Colors.grey,
)),
);
},
);
}
}
| 0 |
mirrored_repositories/FlutterWidgetsSnippets | mirrored_repositories/FlutterWidgetsSnippets/test/widget_test.dart | // This is a basic Flutter widget test.
//
// To perform an interaction with a widget in your test, use the WidgetTester
// utility in the flutter_test package. For example, you can send tap and scroll
// gestures. You can also use WidgetTester to find child widgets in the widget
// tree, read text, and verify that the values of widget properties are correct.
import 'package:flutter/material.dart';
import 'package:flutter_test/flutter_test.dart';
import 'package:widgetssamples/app.dart';
void main() {
testWidgets('Counter increments smoke test', (WidgetTester tester) async {
// Build our app and trigger a frame.
await tester.pumpWidget(const MyApp());
// Verify that our counter starts at 0.
expect(find.text('0'), findsOneWidget);
expect(find.text('1'), findsNothing);
// Tap the '+' icon and trigger a frame.
await tester.tap(find.byIcon(Icons.add));
await tester.pump();
// Verify that our counter has incremented.
expect(find.text('0'), findsNothing);
expect(find.text('1'), findsOneWidget);
});
}
| 0 |
mirrored_repositories/SolatApp | mirrored_repositories/SolatApp/lib/update_set_data.dart | import 'dart:async';
import 'dart:io';
import 'package:http/http.dart' as http;
import 'package:html/dom.dart' as dom;
import 'package:html/parser.dart' as parser;
import 'dart:convert';
import 'package:intl/intl.dart';
class UpdateData {
late dom.Document document;
var dirPath;
UpdateData(http.Response response, var dir) {
this.document = parser.parse(response.body);
this.dirPath = dir;
}
void getParam() {
var params = this.document.getElementsByTagName('tr').getRange(36, 39);
var infoFiqh = this.document.getElementsByTagName('tr').getRange(40, 45);
var dataParamsList = [];
for (var data in params) {
var dataParams = data.text;
dataParamsList.add(dataParams);
}
var infoFiqhList = [];
for (var data in infoFiqh) {
var info = data.text;
infoFiqhList.add(info);
}
var file = File('$dirPath/params.cfg');
if (file.existsSync()) {
file.deleteSync();
}
dataParamsList
.forEach((k) => file.writeAsStringSync("$k\n", mode: FileMode.append));
//infoFiqhList.forEach(
// (k) => file.writeAsStringSync("${k}\n", mode: FileMode.append));
}
void getTable() {
var table = this.document.getElementsByClassName('table_adzan')[0];
var tableBody = table.getElementsByTagName('tbody')[0];
var monthSchedule = tableBody.getElementsByTagName('tr').getRange(4, 35);
var jadwal = [];
for (var day_schedule in monthSchedule) {
var daySch = day_schedule.getElementsByTagName('td');
var timeDay = [];
for (var i = 0; i < daySch.length; i++) {
timeDay.add(daySch[i].text.toString());
}
jadwal.add(timeDay);
}
var file = File('$dirPath/data_jadwal.cfg');
if (file.existsSync()) {
file.deleteSync();
}
jadwal
.forEach((k) => file.writeAsStringSync("$k\n", mode: FileMode.append));
}
void getCity() {
var city = {};
var cities = this.document.getElementsByTagName('option');
for (var i = 0; i < cities.length; i++) {
var val = cities[i].attributes.values;
// ignore: omit_local_variable_types
String valStr = val.toString().replaceAll(')', '').replaceAll('(', '');
city[valStr] = cities[i].text;
}
var file = File('$dirPath/data_kota.cfg');
if (file.existsSync()) {
file.deleteSync();
}
city.forEach(
(k, v) => file.writeAsStringSync("$k : $v\n", mode: FileMode.append));
}
}
class SetData {
var dirPath;
SetData(this.dirPath);
List<dynamic> setListCity() {
File file = File('$dirPath/data_kota.cfg');
List<String> listCity = [];
if (file.existsSync()) {
file
.openRead()
.map(utf8.decode)
.transform(new LineSplitter())
.forEach((l) {
String city = l.split(" : ")[1];
listCity.add(city.toString());
});
}
return listCity;
}
Future<List> setTable() async {
File file = File('$dirPath/data_jadwal.cfg');
var schedule = [];
List scheduleNow = [];
if (file.existsSync()) {
await file
.openRead()
.map(utf8.decode)
.transform(new LineSplitter())
.forEach((l) => schedule.add(l));
DateTime now = DateTime.now();
DateFormat formatter = DateFormat('yyyy-MM-dd');
String dateNow = formatter.format(now).split('-')[2];
//print(dateNow);
schedule.forEach((element) {
String scheduleNew = element.replaceAll(']', '').replaceAll('[', '');
List<String> scheduleList = scheduleNew.split(", ");
String date = scheduleList[0].toString();
//print(scheduleList);
if (dateNow == date) {
scheduleNow = scheduleList;
}
});
}
return scheduleNow;
}
Future<List> setParams() async {
File file = File('$dirPath/params.cfg');
List dataParams = [];
if (file.existsSync()) {
await file
.openRead()
.map(utf8.decode)
.transform(new LineSplitter())
.forEach((l) => dataParams.add(l));
} else {
bool checkTrue = await SetData.checkConn();
if (checkTrue == true) {
http.Response response = await http
.get(Uri.parse('https://jadwalsholat.org/adzan/monthly.php'))
.timeout(Duration(seconds: 10));
//final directory = await getApplicationDocumentsDirectory();
//print(directory.path);
UpdateData upData = new UpdateData(response, dirPath);
upData.getParam();
upData.getCity();
upData.getTable();
SetData setData = new SetData(dirPath);
dataParams = await setData.setParams();
}
}
return dataParams;
}
static Future<bool> checkConn() async {
bool checkTrue = false;
try {
final result = await InternetAddress.lookup('google.com');
if (result.isNotEmpty && result[0].rawAddress.isNotEmpty) {
checkTrue = true;
} else {
checkTrue = false;
}
} on TimeoutException {
//print('Timeout Error: $e');
} on SocketException {
//print('Socket Error: $e');
} on Error {
//print('General Error: $e');
}
return checkTrue;
}
}
| 0 |
mirrored_repositories/SolatApp | mirrored_repositories/SolatApp/lib/update_page.dart | import 'dart:async';
import 'dart:convert';
import 'dart:io';
import 'package:flutter/material.dart';
import 'package:fluttertoast/fluttertoast.dart';
import 'package:intl/intl.dart';
import 'package:shared_preferences/shared_preferences.dart';
import 'package:url_launcher/url_launcher.dart';
import 'package:solat_app/main.dart';
import 'package:solat_app/update_set_data.dart';
import 'package:http/http.dart' as http;
import 'package:path_provider/path_provider.dart';
import 'package:rxdart/rxdart.dart';
StreamController<List<dynamic>> stream2 = BehaviorSubject();
class PageTwo extends StatelessWidget {
const PageTwo({Key? key}) : super(key: key);
@override
Widget build(BuildContext context) {
return UpdatePage(stream2.stream);
}
}
class UpdatePage extends StatefulWidget {
final Stream<List<dynamic>> stream;
UpdatePage(this.stream);
@override
_UpdatePageState createState() => _UpdatePageState();
}
class _UpdatePageState extends State<UpdatePage> {
static String cityNow = "-";
static String lastUpdate = "";
static String dropDownValue = "Ambarawa";
List<dynamic> listCity = [];
void getPref() async {
SharedPreferences preferences = await SharedPreferences.getInstance();
cityNow = preferences.getString('city2') ?? "Jakarta Pusat";
lastUpdate = preferences.getString('lastup') ?? "-----";
}
Future<void> startUpdate() async {
SharedPreferences preferences = await SharedPreferences.getInstance();
final directory = await getApplicationDocumentsDirectory();
File file = new File('${directory.path}/data_kota.cfg');
String city;
String cityFix = "";
var id;
if (file.existsSync()) {
await file
.openRead()
.map(utf8.decode)
.transform(new LineSplitter())
.forEach((dataAndNum) {
city = dataAndNum.split(" : ")[1];
if (city == dropDownValue) {
id = dataAndNum.split(":")[0];
cityFix = city;
preferences.setString('city2', cityFix);
}
});
}
try {
http.Response response = await http
.get(Uri.parse('https://jadwalsholat.org/adzan/monthly.php?id=$id'))
.timeout(Duration(seconds: 10));
if (response.statusCode == 200) {
UpdateData upData = new UpdateData(response, directory.path);
upData.getCity();
upData.getParam();
upData.getTable();
SetData setData = new SetData(directory.path);
var data = await setData.setParams();
var schedule = await setData.setTable();
List scriptUpdate = [data, schedule, cityFix];
streamController.add(scriptUpdate);
Fluttertoast.showToast(
msg: 'Lokasi telah dirubah! ($cityFix)',
toastLength: Toast.LENGTH_LONG,
gravity: ToastGravity.BOTTOM,
);
}
} on TimeoutException catch (e) {
Fluttertoast.showToast(
msg: 'Timeout Exception: Ulangi kembali\n($e)',
toastLength: Toast.LENGTH_LONG,
gravity: ToastGravity.BOTTOM,
);
}
DateTime now = DateTime.now();
DateFormat formatter = DateFormat('dd-MM-yyyy hh:mm:ss');
lastUpdate = formatter.format(now);
preferences.setString('lastup', lastUpdate);
setState(() {
cityNow = cityFix;
});
}
@override
void initState() {
// ignore: todo
// TODO: implement initState
super.initState();
getPref();
widget.stream.listen((data) {
setListCityFirst(data);
});
}
void setListCityFirst(data) {
setState(() {
listCity = data;
});
}
@override
Widget build(BuildContext context) {
return Scaffold(
appBar: AppBar(
backgroundColor: Color(0xFFEE8B60),
centerTitle: true,
elevation: 4,
title: Text(
'Update Lokasi',
style: TextStyle(
fontFamily: 'Poppins',
fontWeight: FontWeight.w400,
fontSize: 20,
color: Color(0xFFFFFDFD),
),
),
),
body: Column(
children: [
Padding(
padding: EdgeInsets.fromLTRB(25, 25, 25, 0),
child: Row(
children: [
Padding(
padding: EdgeInsets.fromLTRB(10, 0, 0, 0),
child: Text(
'Pilih Kota',
style: TextStyle(fontFamily: 'Poppins'),
),
),
Spacer(flex: 3),
Padding(
padding: EdgeInsets.fromLTRB(0, 0, 10, 0),
child: DropdownButton<dynamic>(
value: dropDownValue,
items: listCity.map<DropdownMenuItem>((var value) {
return DropdownMenuItem(
value: value,
child: Text(value),
);
}).toList(),
onChanged: (var newValue) {
setState(() {
dropDownValue = newValue;
});
},
),
),
],
),
),
Padding(
padding: EdgeInsets.fromLTRB(25, 20, 25, 0),
child: Row(
children: [
Padding(
padding: EdgeInsets.fromLTRB(10, 0, 0, 0),
child: Text(
'Kota saat ini: ',
style: TextStyle(fontFamily: 'Poppins'),
),
),
Spacer(),
Padding(
padding: EdgeInsets.fromLTRB(0, 0, 10, 0),
child: Text(
cityNow,
style: TextStyle(fontFamily: 'Poppins'),
),
),
],
),
),
Padding(
padding: EdgeInsets.fromLTRB(45, 10, 45, 20),
child: Builder(
builder: (context) => Center(
child: ElevatedButton(
child: Text(
"Update",
style: TextStyle(
fontFamily: 'Poppins',
fontSize: 20,
),
),
onPressed: () => startUpdate(),
),
),
),
),
Center(
child: Padding(
padding: EdgeInsets.only(bottom: 20),
child: Text("Last Update: " + lastUpdate),
),
),
Padding(
padding: EdgeInsets.fromLTRB(35, 0, 35, 0),
child: Align(
alignment: Alignment.center,
child: Row(
children: [
Text("Data diambil dari "),
InkWell(
child: Text(
"jadwalsholat.org",
style: TextStyle(
color: Color(0xFF0000EE),
decoration: TextDecoration.underline,
),
),
onTap: () => launch('http://jadwalsholat.org'),
)
],
),
),
),
],
),
);
}
}
| 0 |
mirrored_repositories/SolatApp | mirrored_repositories/SolatApp/lib/main.dart | import 'dart:async';
import 'package:flutter/material.dart';
import 'main_page.dart';
StreamController<List> streamController = new StreamController<List>();
void main() {
runApp(PageOne());
}
class PageOne extends StatelessWidget {
const PageOne({Key? key}) : super(key: key);
@override
Widget build(BuildContext context) {
return MaterialApp(
title: "SolatApp",
home: HomePage(streamController.stream),
debugShowCheckedModeBanner: false);
}
}
| 0 |
mirrored_repositories/SolatApp | mirrored_repositories/SolatApp/lib/main_page.dart | import 'dart:async';
import 'package:flutter/material.dart';
import 'package:intl/intl.dart';
import 'package:path_provider/path_provider.dart';
import 'package:shared_preferences/shared_preferences.dart';
import 'update_page.dart';
import 'update_set_data.dart';
class HomePage extends StatefulWidget {
final Stream<List> stream;
HomePage(this.stream);
@override
_HomePageState createState() => _HomePageState();
}
class _HomePageState extends State<HomePage> {
String terbitTime = '-';
String shubuhTime = '-';
String imsyakTime = '-';
String dhuhaTime = '-';
String dzuhurTime = '-';
String maghribTime = '-';
String ashrTime = '-';
String isyaTime = '-';
String param1 = '-';
String param2 = '-';
String param3 = '-';
String city = '-';
String tanggal = DateFormat('EEEE, d MMM yyyy').format(DateTime.now());
Future<void> getData() async {
SharedPreferences preferences = await SharedPreferences.getInstance();
final directory = await getApplicationDocumentsDirectory();
SetData setData = new SetData(directory.path);
var params = await setData.setParams();
List<dynamic> listCity = setData.setListCity();
var schedule = await setData.setTable();
var data = [params, schedule];
stream2.add(listCity);
setState(() {
param1 = data[0][0];
param2 = data[0][1];
param3 = data[0][2];
imsyakTime = data[1][1];
shubuhTime = data[1][2];
terbitTime = data[1][3];
dhuhaTime = data[1][4];
dzuhurTime = data[1][5];
ashrTime = data[1][6];
maghribTime = data[1][7];
isyaTime = data[1][8];
String citySet = preferences.getString('city') ?? "Jakarta Pusat";
city = 'Wilayah $citySet';
});
}
@override
void initState() {
super.initState();
WidgetsBinding.instance!.addPostFrameCallback((_) => getData());
widget.stream.listen((data) {
updateCity(data);
});
}
void updateCity(List data) async {
SharedPreferences preferences = await SharedPreferences.getInstance();
setState(() {
param1 = data[0][0];
param2 = data[0][1];
param3 = data[0][2];
imsyakTime = data[1][1];
shubuhTime = data[1][2];
terbitTime = data[1][3];
dhuhaTime = data[1][4];
dzuhurTime = data[1][5];
ashrTime = data[1][6];
maghribTime = data[1][7];
isyaTime = data[1][8];
city = 'Wilayah ${data[2]}';
preferences.setString('city', data[2]);
});
}
@override
Widget build(BuildContext context) {
return Scaffold(
appBar: AppBar(
backgroundColor: Color(0xFFEE8B60),
centerTitle: true,
elevation: 4,
title: Text(
'SolatApp',
style: TextStyle(
fontFamily: 'Poppins',
fontWeight: FontWeight.w600,
fontSize: 20,
color: Color(0xFFFFFDFD),
),
),
),
body: SingleChildScrollView(
child: Column(
mainAxisAlignment: MainAxisAlignment.start,
crossAxisAlignment: CrossAxisAlignment.stretch,
children: [
Column(
children: [
Container(
padding: EdgeInsets.fromLTRB(25, 15, 0, 0),
child: Align(
alignment: Alignment.centerLeft,
child: Text(
city,
style: TextStyle(
fontFamily: 'Poppins',
fontSize: 20,
fontWeight: FontWeight.w600,
),
),
),
),
Container(
padding: EdgeInsets.fromLTRB(25, 5, 0, 15),
child: Align(
alignment: Alignment.centerLeft,
child: Text(
tanggal,
style: TextStyle(
fontFamily: "Poppins",
fontSize: 15,
),
),
),
),
],
),
getPadding('Imsyak', imsyakTime, Color(0xFFDCD68E)),
getPadding('Shubuh', shubuhTime, Color(0xFFDCE69E)),
getPadding('Terbit', terbitTime, Color(0xFFDCD68E)),
getPadding('Dhuha', dhuhaTime, Color(0xFFDCE69E)),
getPadding('Dzuhur', dzuhurTime, Color(0xFFDCD68E)),
getPadding('Ashr', ashrTime, Color(0xFFDCE69E)),
getPadding('Maghrib', maghribTime, Color(0xFFDCD68E)),
getPadding('Isya', isyaTime, Color(0xFFDCE69E)),
Padding(
padding: EdgeInsets.fromLTRB(25, 10, 25, 0),
child: Container(
child: Column(
children: [
Divider(),
Text(
param1,
textAlign: TextAlign.center,
),
Divider(),
Text(
param2,
textAlign: TextAlign.center,
),
Divider(),
Text(
param3,
textAlign: TextAlign.center,
),
Divider(),
Container(
width: 100,
height: 100,
clipBehavior: Clip.antiAlias,
decoration: BoxDecoration(
shape: BoxShape.circle,
),
child: Image.asset('assets/images/compass.png'),
),
],
),
),
),
Padding(
padding: EdgeInsets.fromLTRB(45, 10, 45, 20),
child: Builder(
builder: (context) => Center(
child: ElevatedButton(
child: Text(
"Update Lokasi",
style: TextStyle(
fontFamily: 'Poppins',
fontSize: 20,
),
),
onPressed: () {
Navigator.push(context,
MaterialPageRoute(builder: (context) => PageTwo()));
},
),
),
),
),
],
),
),
);
}
}
Padding getPadding(String prayTime, String time, Color hexColor) {
return Padding(
padding: EdgeInsets.fromLTRB(25, 0, 25, 5),
child: Container(
width: 100,
height: 50,
decoration: BoxDecoration(
color: hexColor,
borderRadius: BorderRadius.circular(20),
),
child: Row(
children: [
Padding(
padding: EdgeInsets.fromLTRB(20, 0, 0, 0),
child: Text(
prayTime,
style: TextStyle(
fontFamily: 'Poppins',
fontSize: 15,
),
),
),
Spacer(),
Padding(
padding: EdgeInsets.fromLTRB(0, 0, 20, 0),
child: Text(
time,
style: TextStyle(
fontFamily: 'Poppins',
fontWeight: FontWeight.w800,
fontSize: 17,
),
),
),
],
),
),
);
}
| 0 |
mirrored_repositories/SolatApp | mirrored_repositories/SolatApp/test/widget_test.dart | // This is a basic Flutter widget test.
//
// To perform an interaction with a widget in your test, use the WidgetTester
// utility that Flutter provides. For example, you can send tap and scroll
// gestures. You can also use WidgetTester to find child widgets in the widget
// tree, read text, and verify that the values of widget properties are correct.
import 'package:flutter/material.dart';
import 'package:flutter_test/flutter_test.dart';
import 'package:solat_app/main.dart';
void main() {
testWidgets('Counter increments smoke test', (WidgetTester tester) async {
// Build our app and trigger a frame.
await tester.pumpWidget(PageOne());
// Verify that our counter starts at 0.
expect(find.text('0'), findsOneWidget);
expect(find.text('1'), findsNothing);
// Tap the '+' icon and trigger a frame.
await tester.tap(find.byIcon(Icons.add));
await tester.pump();
// Verify that our counter has incremented.
expect(find.text('0'), findsNothing);
expect(find.text('1'), findsOneWidget);
});
}
| 0 |
mirrored_repositories/github_client | mirrored_repositories/github_client/lib/main_model.dart | import 'dart:convert';
import 'package:http/http.dart' as http;
class GitHubApi {
final http.Client client;
GitHubApi(this.client);
Future<List<dynamic>> getRepoList() async {
final response = await client.get('https://api.github.com/users/ragnor-rs/repos');
if (response.statusCode == 200) {
return json.decode(response.body);
} else {
throw Exception('Failed to load repo list');
}
}
}
| 0 |
mirrored_repositories/github_client | mirrored_repositories/github_client/lib/main_presentation.dart | import 'package:flutter/material.dart';
import 'package:github_client/main_component.dart';
import 'package:github_client/repos/repo_list_presentation.dart';
class MainComponentProvider extends InheritedWidget {
final MainComponent mainComponent;
MainComponentProvider({this.mainComponent, child}): super(child: child);
@override
bool updateShouldNotify(MainComponentProvider oldWidget) {
return mainComponent != oldWidget.mainComponent;
}
static MainComponent of(BuildContext context) =>
(context.inheritFromWidgetOfExactType(MainComponentProvider) as MainComponentProvider).mainComponent;
}
class GitHubClientApp extends StatelessWidget {
@override
Widget build(BuildContext context) {
return MainComponentProvider(
mainComponent: MainComponentImpl(),
child: MaterialApp(
title: 'Flutter Demo',
home: Scaffold(
appBar: AppBar(
title: Text("GitHub client"),
),
body: RepoListPage(),
)
),
);
}
}
| 0 |
mirrored_repositories/github_client | mirrored_repositories/github_client/lib/main.dart | import 'package:flutter/material.dart';
import 'package:github_client/main_presentation.dart';
void main() {
runApp(
GitHubClientApp()
);
}
| 0 |
mirrored_repositories/github_client | mirrored_repositories/github_client/lib/main_component.dart | import 'package:github_client/main_model.dart';
import 'package:github_client/repos/repo_component.dart';
import 'package:http/http.dart' as http;
abstract class MainComponent {
RepoComponent get repoComponent;
}
class MainComponentImpl implements MainComponent {
http.Client _httpClient;
GitHubApi _gitHubApi;
RepoComponent _repoComponent;
MainComponentImpl() {
_httpClient = http.Client();
_gitHubApi = GitHubApi(httpClient);
_repoComponent = RepoComponentImpl(gitHubApi);
}
get httpClient => _httpClient;
get gitHubApi => _gitHubApi;
@override
get repoComponent => _repoComponent;
} | 0 |
mirrored_repositories/github_client/lib | mirrored_repositories/github_client/lib/repos/repo_list_presentation.dart | import 'package:flutter/material.dart';
import 'package:flutter_bloc/flutter_bloc.dart';
import 'package:github_client/main_presentation.dart';
import 'package:github_client/repos/repo_list_bloc.dart';
class RepoListPage extends StatefulWidget {
@override
State<StatefulWidget> createState() => _RepoListPageState();
}
class _RepoListPageState extends State<RepoListPage> {
RepoListBloc _bloc;
@override
Widget build(BuildContext context) {
if (_bloc == null) {
var mainComponent = MainComponentProvider.of(context);
_bloc = RepoListBloc(mainComponent.repoComponent);
}
return BlocBuilder(
bloc: _bloc,
builder: (BuildContext context, RepoListState state) {
if (state.isLoading) {
return Center(
child: Text("Loading..."),
);
} else if (state.isError) {
return Center(
child: Text("Error!"),
);
} else {
return ListView(
children: state.result.map((repo) => Text(repo.name)).toList(),
);
}
},
);
}
@override
void dispose() {
super.dispose();
_bloc.dispose();
}
} | 0 |
mirrored_repositories/github_client/lib | mirrored_repositories/github_client/lib/repos/repo_model.dart | import 'package:github_client/main_model.dart';
abstract class RepoRepository {
Future<List<Repo>> getRepoList();
}
class RepoRepositoryImpl implements RepoRepository {
final GitHubApi _api;
RepoRepositoryImpl(this._api);
@override
Future<List<Repo>> getRepoList() async {
List<Repo> result = [];
final list = await _api.getRepoList();
for (var item in list) {
result.add(Repo.fromJson(item));
}
return result;
}
}
class Repo {
final int id;
final String name;
final String description;
Repo({this.id, this.name, this.description});
factory Repo.fromJson(Map<String, dynamic> json) =>
Repo(
id: json['id'],
name: json['name'],
description: json['description'],
);
} | 0 |
mirrored_repositories/github_client/lib | mirrored_repositories/github_client/lib/repos/repo_component.dart | import 'package:github_client/main_model.dart';
import 'package:github_client/repos/repo_model.dart';
abstract class RepoComponent {
RepoRepository get repoRepository;
}
class RepoComponentImpl implements RepoComponent {
RepoRepository _repoRepository;
RepoComponentImpl(GitHubApi gitHubApi) {
_repoRepository = RepoRepositoryImpl(gitHubApi);
}
@override
get repoRepository => _repoRepository;
} | 0 |
mirrored_repositories/github_client/lib | mirrored_repositories/github_client/lib/repos/repo_list_bloc.dart | import 'package:bloc/bloc.dart';
import 'package:github_client/repos/repo_model.dart';
import 'package:github_client/repos/repo_component.dart';
class RepoListBloc extends Bloc<FetchRepoListEvent, RepoListState> {
final RepoRepository _repository;
RepoListBloc(RepoComponent serviceContainer) : _repository = serviceContainer.repoRepository {
dispatch(FetchRepoListEvent());
}
@override
RepoListState get initialState => RepoListState.initial();
@override
Stream<RepoListState> mapEventToState(RepoListState state, FetchRepoListEvent event) async* {
try {
final result = await _repository.getRepoList();
yield RepoListState.success(result);
} catch (_) {
yield RepoListState.failure();
}
}
}
class FetchRepoListEvent {}
class RepoListState {
final bool isLoading;
final bool isError;
final List<Repo> result;
RepoListState(this.isLoading, this.isError, this.result);
factory RepoListState.initial() => RepoListState(true, false, null);
factory RepoListState.success(List<Repo> result) => RepoListState(false, false, result);
factory RepoListState.failure() => RepoListState(false, true, null);
} | 0 |
mirrored_repositories/github_client | mirrored_repositories/github_client/test/main_presentation.dart | import 'package:flutter/material.dart';
import 'package:github_client/main_component.dart';
import 'package:github_client/main_presentation.dart';
import 'main_component.dart';
final MainComponent mainComponent = MainComponentMock();
MainComponentProvider makeWidgetTestable(Widget widget) {
return MainComponentProvider(
mainComponent: mainComponent,
child: MaterialApp(home: widget),
);
}
| 0 |
mirrored_repositories/github_client | mirrored_repositories/github_client/test/main_component.dart | import 'package:github_client/main_component.dart';
import 'package:github_client/repos/repo_component.dart';
import 'repos/repo_component.dart';
class MainComponentMock implements MainComponent {
RepoComponent _repoComponent;
MainComponentMock() {
_repoComponent = RepoComponentMock();
}
@override
RepoComponent get repoComponent => _repoComponent;
}
| 0 |
mirrored_repositories/github_client/test | mirrored_repositories/github_client/test/repos/repo_model_test.dart | import 'dart:convert';
import 'package:flutter_test/flutter_test.dart';
import 'package:github_client/main_model.dart';
import 'package:github_client/repos/repo_model.dart';
import 'package:http/http.dart';
import 'package:http/testing.dart';
void main() {
var client = MockClient((request) async {
var url = request.url.toString();
if (url == 'https://api.github.com/users/ragnor-rs/repos') {
final result = [{
'id': 123,
'name': 'test',
'description': 'description',
}];
return Response(json.encode(result), 200);
} else {
throw Exception("Unknown url: $url");
}
});
test("RepoRepository", () async {
var repoRepository = RepoRepositoryImpl(GitHubApi(client));
var repoList = await repoRepository.getRepoList();
expect(repoList[0].id, 123);
expect(repoList[0].name, 'test');
expect(repoList[0].description, 'description');
});
} | 0 |
mirrored_repositories/github_client/test | mirrored_repositories/github_client/test/repos/repo_list_presentation_test.dart | import 'package:flutter_test/flutter_test.dart';
import 'package:github_client/repos/repo_list_presentation.dart';
import 'package:mockito/mockito.dart';
import '../main_presentation.dart';
void main() {
testWidgets('Repo list loads items', (WidgetTester tester) async {
var widget = RepoListPage();
await tester.pumpWidget(
makeWidgetTestable(widget)
);
verify(mainComponent.repoComponent.repoRepository.getRepoList()).called(1);
});
}
| 0 |
mirrored_repositories/github_client/test | mirrored_repositories/github_client/test/repos/repo_model.dart | import 'package:github_client/repos/repo_model.dart';
import 'package:mockito/mockito.dart';
class RepoRepositoryMock extends Mock implements RepoRepository {} | 0 |
mirrored_repositories/github_client/test | mirrored_repositories/github_client/test/repos/repo_component.dart | import 'package:github_client/repos/repo_component.dart';
import 'package:github_client/repos/repo_model.dart';
import 'repo_model.dart';
class RepoComponentMock extends RepoComponent {
RepoRepository _repoRepository = RepoRepositoryMock();
@override
RepoRepository get repoRepository => _repoRepository;
} | 0 |
mirrored_repositories/github_client | mirrored_repositories/github_client/test_driver/app.dart | import 'package:flutter_driver/driver_extension.dart';
import 'package:github_client/main.dart' as app;
void main() {
// This line enables the extension
enableFlutterDriverExtension();
app.main();
}
| 0 |
mirrored_repositories/github_client | mirrored_repositories/github_client/test_driver/app_test.dart | // Imports the Flutter Driver API
import 'package:flutter_driver/flutter_driver.dart' as flutter_driver;
import 'package:test/test.dart';
void main() {
group('GitHub client', () {
flutter_driver.FlutterDriver driver;
// Connect to the Flutter driver before running any tests
setUpAll(() async {
driver = await flutter_driver.FlutterDriver.connect();
});
// Close the connection to the driver after the tests have completed
tearDownAll(() async {
if (driver != null) {
driver.close();
}
});
test('Repo list loaded', () async {
// Check whether 'dali' item exists
expect(await driver.getText(flutter_driver.find.text('dali')), 'dali');
});
});
}
| 0 |
mirrored_repositories/pigeon | mirrored_repositories/pigeon/lib/main.dart | import 'package:flutter/material.dart';
import 'package:flutter/services.dart';
import 'package:get/get.dart';
import 'package:pigeon1/view/detaildevices.dart';
import 'view/home.dart';
void main() {
runApp(MyApp());
}
class MyApp extends StatelessWidget {
const MyApp({Key? key}) : super(key: key);
@override
Widget build(BuildContext context) {
SystemChrome.setPreferredOrientations([
DeviceOrientation.portraitUp,
]);
SystemChrome.setSystemUIOverlayStyle(
SystemUiOverlayStyle(
systemNavigationBarColor: Colors.transparent,
statusBarColor: Colors.transparent, // status bar color
statusBarIconBrightness: Brightness.dark, // status bar icons' color
systemNavigationBarIconBrightness: Brightness.dark,
),
);
return GetMaterialApp(
debugShowCheckedModeBanner: false,
theme: ThemeData(
fontFamily: 'UR',
elevatedButtonTheme: ElevatedButtonThemeData(
style: ElevatedButton.styleFrom(
minimumSize: Size(Get.width, 40),
primary: Colors.white,
shape: new RoundedRectangleBorder(
borderRadius: new BorderRadius.circular(15),
),
),
),
),
initialRoute: '/',
getPages: [
GetPage(name: "/", page: () => Home()),
GetPage(
name: "/detail",
page: () => DetailDevices(),
transition: Transition.rightToLeftWithFade,
),
],
);
}
}
| 0 |
mirrored_repositories/pigeon/lib | mirrored_repositories/pigeon/lib/view/detaildevices.dart | import 'package:flutter/material.dart';
import 'package:get/get.dart';
import 'package:pigeon1/controller/devices_controller.dart';
import 'package:pigeon1/model/modeldevices.dart';
import 'package:pigeon1/widget/customswitch.dart';
import 'package:pigeon1/widget/devices/switch.dart';
import 'package:pigeon1/widget/devices/tv/remote_tv.dart';
import 'package:pigeon1/widget/devices/wifi/remote_wifi.dart';
import 'package:pigeon1/widget/formatings.dart';
import 'package:pigeon1/widget/icon/findIcons.dart';
import 'package:pigeon1/widget/shadow.dart';
import 'package:pigeon1/widget/textyle.dart';
class DetailDevices extends StatefulWidget {
const DetailDevices({Key? key}) : super(key: key);
@override
_DetailDevicesState createState() => _DetailDevicesState();
}
class _DetailDevicesState extends State<DetailDevices> {
@override
Widget build(BuildContext context) {
double width = MediaQuery.of(context).size.width;
// double height = MediaQuery.of(context).size.height;
return GetBuilder<DevicesController>(
init: DevicesController(),
builder: (val) {
int? id = int.tryParse(Get.parameters['id'].toString());
var a = val.dataDevices.where((element) => id == element.id).first;
List<ModelDevices> rec =
val.dataDevices.where((element) => element.icon == a.icon).toList();
rec.removeWhere((element) => element.id == a.id);
// var dhms = Formatings.rangeDate(use: a.use);
print(id);
return GestureDetector(
onTap: () {
FocusScope.of(context).unfocus();
},
child: Scaffold(
resizeToAvoidBottomInset: false,
backgroundColor: Colors.white,
extendBodyBehindAppBar: true,
appBar: AppBar(
shadowColor: Colors.transparent,
backgroundColor: Colors.transparent,
elevation: 0,
automaticallyImplyLeading: false,
titleSpacing: 15,
title: SizedBox(
width: width,
child: Wrap(
alignment: WrapAlignment.spaceBetween,
crossAxisAlignment: WrapCrossAlignment.center,
children: [
GestureDetector(
onTap: () {
Get.back();
},
child: Container(
width: 45,
height: 45,
decoration: BoxDecoration(
color: Colors.white,
shape: BoxShape.circle,
boxShadow: [
boxShadow,
]),
child: Icon(
Icons.arrow_back_rounded,
color: Colors.blue,
),
),
),
Text(
a.name,
style: txt15bs,
),
SizedBox(
width: 45,
height: 45,
),
],
),
),
),
body: SingleChildScrollView(
child: Column(
mainAxisAlignment: MainAxisAlignment.start,
crossAxisAlignment: CrossAxisAlignment.start,
children: [
SizedBox(
height: width / 4,
),
Center(
child: AnimatedContainer(
duration: Duration(milliseconds: 300),
width: width / 2.8,
height: width / 2.8,
decoration: BoxDecoration(
shape: BoxShape.circle,
color: Colors.white,
boxShadow: [
!a.active
? boxShadow
: BoxShadow(
spreadRadius: width / 12,
blurRadius: 15,
color: Colors.blue.withOpacity(0.2),
),
]),
child: Column(
crossAxisAlignment: CrossAxisAlignment.center,
mainAxisAlignment: MainAxisAlignment.center,
children: [
Icon(
findIcons(icon: a.icon),
size: width / 6,
color: a.active ? Colors.blue : Colors.grey,
),
SizedBox(
height: 5,
),
Text(
a.konsumsi.toString() + " kWh",
style: txt12b07s,
)
],
),
),
),
SizedBox(
height: 20,
),
Container(
width: width,
padding: EdgeInsets.all(15),
margin: EdgeInsets.fromLTRB(15, 0, 15, 0),
decoration: BoxDecoration(
color: Colors.white,
boxShadow: [boxShadow],
borderRadius: BorderRadius.circular(10),
),
child: Wrap(
alignment: WrapAlignment.spaceBetween,
crossAxisAlignment: WrapCrossAlignment.center,
children: [
StreamBuilder(
stream: Stream.periodic(Duration(seconds: 1))
.asBroadcastStream(),
builder: (ctx, snap) {
var dhms = Formatings.rangeDate(use: a.use);
if (!a.active)
return SizedBox(
width: 0,
height: 0,
);
else if (dhms.hour >= 1 && dhms.hour <= 24)
return Text(
dhms.hour.toString() + " Jam",
style: TextStyle(
color: Colors.red,
fontSize: 12,
),
);
else if (dhms.hour > 24)
return Text(
dhms.day.toString() + " Hari",
style: TextStyle(
color: Colors.red,
fontSize: 12,
),
);
else if (dhms.second < 60)
return Text(
dhms.second.toString() + " Detik",
style: TextStyle(
color: Colors.red,
fontSize: 12,
),
);
else
return Text(
dhms.minutes.toString() + " Menit",
style: TextStyle(
color: Colors.red,
fontSize: 12,
),
);
},
),
CustomSwitch(
value: a.active,
onChange: (value) {
val.updateActive(
active: value,
id: a.id,
dateTime: DateTime.now());
},
width: 50,
heigth: 25,
)
],
),
),
SizedBox(
height: 20,
),
if (a.icon == 1)
a.active
? remoteTv(width: width, context: context)
: SizedBox(
width: 0,
height: 0,
),
if (a.icon == 2)
a.active
? RemoteWifi()
: SizedBox(
width: 0,
height: 0,
)
else
SizedBox(
width: 0,
height: 0,
),
SizedBox(
height: 20,
),
Padding(
padding: const EdgeInsets.symmetric(horizontal: 20),
child: Wrap(
alignment: WrapAlignment.start,
crossAxisAlignment: WrapCrossAlignment.start,
spacing: 15,
runSpacing: 15,
children: [
for (var b in rec)
Switchh(
id: b.id,
iconn: b.icon,
name: b.name,
konsumsi: b.konsumsi,
use: b.use,
active: b.active,
),
],
),
),
SizedBox(
height: 20,
),
],
),
),
),
);
},
);
}
}
| 0 |
mirrored_repositories/pigeon/lib | mirrored_repositories/pigeon/lib/view/home.dart | import 'package:flutter/material.dart';
import 'package:pigeon1/widget/devices/devices.dart';
import 'package:pigeon1/widget/home/greeting.dart';
import 'package:pigeon1/widget/home/outofusage.dart';
import 'package:pigeon1/widget/home/penggunaan.dart';
class Home extends StatefulWidget {
@override
_HomeState createState() => _HomeState();
}
class _HomeState extends State<Home> {
@override
Widget build(BuildContext context) {
double? width = MediaQuery.of(context).size.width;
return GestureDetector(
child: Scaffold(
backgroundColor: Colors.white,
body: SingleChildScrollView(
child: Column(
mainAxisAlignment: MainAxisAlignment.start,
crossAxisAlignment: CrossAxisAlignment.start,
children: [
greeting(),
SizedBox(
height: 20,
),
penggunaan(width),
SizedBox(
height: 20,
),
outOfUsage(width),
SizedBox(
height: 20,
),
devices(width),
SizedBox(
height: 20,
),
],
),
),
),
);
}
}
| 0 |
mirrored_repositories/pigeon/lib | mirrored_repositories/pigeon/lib/model/modelUserWifi.dart | // import 'dart:convert';
// ModelDevices modelDevicesFromMap(String? str) =>
// ModelDevices.fromMap(json.decode(str! ));
// String modelDevicesToMap(ModelDevices data) => json.encode(data.toMap());
class ModelUserWifi {
ModelUserWifi({
required this.id,
required this.name,
required this.mac,
required this.ip,
});
int id;
String name, mac, ip;
factory ModelUserWifi.fromMap(Map<String, dynamic> json) => ModelUserWifi(
id: json["id"],
name: json["name"],
mac: json["mac"],
ip: json["ip"],
);
Map<String, dynamic> toMap() => {
"id": id,
"name": name,
"mac": mac,
"ip": ip,
};
}
| 0 |
mirrored_repositories/pigeon/lib | mirrored_repositories/pigeon/lib/model/modelRangeDate.dart | // import 'dart:convert';
// ModelDevices modelDevicesFromMap(String? str) =>
// ModelDevices.fromMap(json.decode(str! ));
// String modelDevicesToMap(ModelDevices data) => json.encode(data.toMap());
class ModelRangeDate {
ModelRangeDate({
required this.day,
required this.hour,
required this.minutes,
required this.second,
});
int day, hour, minutes, second;
factory ModelRangeDate.fromMap(Map<String, dynamic> json) => ModelRangeDate(
day: json["day"],
hour: json["hour"],
minutes: json["minutes"],
second: json["second"],
);
Map<String, dynamic> toMap() => {
"day": day,
"hour": hour,
"minutes": minutes,
"second": second,
};
}
| 0 |
mirrored_repositories/pigeon/lib | mirrored_repositories/pigeon/lib/model/modeldevices.dart | // import 'dart:convert';
// ModelDevices modelDevicesFromMap(String? str) =>
// ModelDevices.fromMap(json.decode(str! ));
// String modelDevicesToMap(ModelDevices data) => json.encode(data.toMap());
class ModelDevices {
ModelDevices({
required this.id,
required this.icon,
required this.name,
required this.konsumsi,
required this.use,
required this.active,
});
int icon, id;
String name;
double konsumsi;
DateTime use;
bool active;
factory ModelDevices.fromMap(Map<String, dynamic> json) => ModelDevices(
id: json["id"],
icon: json["icon"],
name: json["name"],
konsumsi: json["konsumsi"].toDouble(),
use: json["use"],
active: json["active"],
);
Map<String, dynamic> toMap() => {
"id": id,
"icon": icon,
"name": name,
"konsumsi": konsumsi,
"use": use,
"active": active,
};
}
| 0 |
mirrored_repositories/pigeon/lib | mirrored_repositories/pigeon/lib/widget/customswitch.dart | import 'package:flutter/material.dart';
import 'package:pigeon1/widget/shadow.dart';
class CustomSwitch extends StatefulWidget {
final bool value;
final ValueChanged<bool> onChange;
final double width;
final double heigth;
CustomSwitch({
required this.value,
required this.onChange,
required this.width,
required this.heigth,
});
@override
_CustomSwitchState createState() => _CustomSwitchState();
}
class _CustomSwitchState extends State<CustomSwitch> {
@override
Widget build(BuildContext context) {
return InkWell(
onTap: () {
widget.value == false ? widget.onChange(true) : widget.onChange(false);
},
child: AnimatedContainer(
duration: Duration(milliseconds: 200),
padding: EdgeInsets.only(top: 1, bottom: 1),
width: widget.width,
height: widget.heigth,
decoration: BoxDecoration(
color: widget.value ? Colors.blue : Colors.grey.withOpacity(0.3),
borderRadius: BorderRadius.circular(60),
boxShadow: [
boxShadow,
]),
child: AnimatedAlign(
duration: Duration(milliseconds: 200),
alignment:
widget.value ? Alignment.centerRight : Alignment.centerLeft,
child: Container(
width: widget.heigth,
height: widget.heigth,
decoration: BoxDecoration(
color: Colors.white,
shape: BoxShape.circle,
),
),
),
),
);
}
}
| 0 |
mirrored_repositories/pigeon/lib | mirrored_repositories/pigeon/lib/widget/shadow.dart | import 'package:flutter/material.dart';
BoxShadow boxShadow = BoxShadow(
blurRadius: 15,
color: Colors.black.withOpacity(0.1),
);
BoxShadow boxShadow2 = BoxShadow(
blurRadius: 15,
color: Colors.blue.withOpacity(0.2),
);
| 0 |
mirrored_repositories/pigeon/lib | mirrored_repositories/pigeon/lib/widget/formatings.dart | import 'package:pigeon1/model/modelRangeDate.dart';
class Formatings {
static ModelRangeDate rangeDate({required DateTime use}) {
DateTime a = DateTime.now();
var b = a.difference(use);
return ModelRangeDate(
day: b.inDays,
hour: b.inHours,
minutes: b.inMinutes,
second: b.inSeconds);
}
}
| 0 |
mirrored_repositories/pigeon/lib | mirrored_repositories/pigeon/lib/widget/textyle.dart | import 'package:flutter/material.dart';
TextStyle? txt15bs =
TextStyle(color: Colors.black, fontSize: 18, fontWeight: FontWeight.bold);
TextStyle? txt12b07s = TextStyle(
color: Colors.black.withOpacity(0.7),
fontSize: 12,
);
| 0 |
mirrored_repositories/pigeon/lib/widget | mirrored_repositories/pigeon/lib/widget/devices/switch.dart | // import 'package:flutter/foundation.dart';
import 'package:flutter/material.dart';
import 'package:get/get.dart';
import 'package:pigeon1/controller/devices_controller.dart';
import 'package:pigeon1/widget/customswitch.dart';
import 'package:pigeon1/widget/icon/findIcons.dart';
import 'package:pigeon1/widget/shadow.dart';
import 'package:pigeon1/widget/textyle.dart';
import '../formatings.dart';
class Switchh extends StatefulWidget {
final int iconn, id;
final String name;
final double konsumsi;
final bool active;
final DateTime use;
Switchh({
required this.id,
required this.iconn,
required this.name,
required this.konsumsi,
required this.use,
required this.active,
});
@override
_SwitchhState createState() => _SwitchhState();
}
class _SwitchhState extends State<Switchh> {
DevicesController control = Get.put(DevicesController());
@override
Widget build(BuildContext context) {
double width = MediaQuery.of(context).size.width;
return AnimatedContainer(
duration: Duration(seconds: 300),
padding: EdgeInsets.all(15),
width: width / 2.37,
decoration: BoxDecoration(
color: Colors.white,
borderRadius: BorderRadius.circular(15),
boxShadow: [widget.active ? boxShadow2 : boxShadow],
),
child: Column(
crossAxisAlignment: CrossAxisAlignment.start,
children: [
Row(
mainAxisAlignment: MainAxisAlignment.spaceBetween,
children: [
Icon(
findIcons(icon: widget.iconn),
color: widget.active ? Colors.blue : Colors.grey,
),
CustomSwitch(
width: 50,
heigth: 25,
value: widget.active,
onChange: (val) {
// var q = control.dataDevices
// .where((element) => element.id == widget.id)
// .first;
// q.active = val;
// control.update();
control.updateActive(
active: val, id: widget.id, dateTime: DateTime.now());
// print(q.id);
},
),
],
),
SizedBox(
height: 10,
),
InkWell(
onTap: () {
Get.toNamed('/detail?id=' + widget.id.toString());
},
child: Column(
crossAxisAlignment: CrossAxisAlignment.start,
children: [
Text(
widget.name,
style: TextStyle(
fontSize: 13,
fontWeight: FontWeight.bold,
),
),
SizedBox(
height: 2,
),
Text(
"Konsumsi " + widget.konsumsi.toString() + " kWh",
style: txt12b07s,
),
SizedBox(
height: 10,
),
StreamBuilder(
stream:
Stream.periodic(Duration(seconds: 1)).asBroadcastStream(),
builder: (ctx, snap) {
var dhms = Formatings.rangeDate(use: widget.use);
if (!widget.active)
return SizedBox(
width: 0,
height: 0,
);
else if (dhms.hour >= 1 && dhms.hour <= 24)
return Text(
dhms.hour.toString() + " Jam",
style: TextStyle(
color: Colors.red,
fontSize: 12,
),
);
else if (dhms.hour > 24)
return Text(
dhms.day.toString() + " Hari",
style: TextStyle(
color: Colors.red,
fontSize: 12,
),
);
else if (dhms.second < 60)
return Text(
dhms.second.toString() + " Detik",
style: TextStyle(
color: Colors.red,
fontSize: 12,
),
);
else
return Text(
dhms.minutes.toString() + " Menit",
style: TextStyle(
color: Colors.red,
fontSize: 12,
),
);
},
)
],
),
),
],
),
);
}
}
| 0 |
mirrored_repositories/pigeon/lib/widget | mirrored_repositories/pigeon/lib/widget/devices/devices.dart | import 'package:flutter/cupertino.dart';
import 'package:flutter/material.dart';
import 'package:get/state_manager.dart';
import 'package:pigeon1/controller/devices_controller.dart';
import 'package:pigeon1/widget/devices/switch.dart';
import '../textyle.dart';
Widget devices(double width) {
return GetBuilder<DevicesController>(
init: DevicesController(),
builder: (val) {
return Column(
crossAxisAlignment: CrossAxisAlignment.start,
children: [
Padding(
padding: const EdgeInsets.symmetric(horizontal: 10),
child: Text(
"Perangkatku",
style: txt15bs,
),
),
SizedBox(
height: 10,
),
Padding(
padding: const EdgeInsets.symmetric(horizontal: 20),
child: Wrap(
spacing: 15,
runSpacing: 15,
children: [
for (var a in val.dataDevices)
Switchh(
id: a.id,
iconn: a.icon,
name: a.name,
konsumsi: a.konsumsi,
use: a.use,
active: a.active,
),
],
),
),
],
);
},
);
}
| 0 |
mirrored_repositories/pigeon/lib/widget/devices | mirrored_repositories/pigeon/lib/widget/devices/tv/search.dart | import 'dart:ui';
import 'package:flutter/material.dart';
class Search extends StatefulWidget {
const Search({Key? key}) : super(key: key);
@override
_SearchState createState() => _SearchState();
}
class _SearchState extends State<Search> {
TextEditingController txt = TextEditingController();
@override
Widget build(BuildContext context) {
double w = MediaQuery.of(context).size.width;
return (BackdropFilter(
filter: ImageFilter.blur(sigmaX: 10, sigmaY: 10),
child: Container(
width: w,
height: 40,
decoration: BoxDecoration(
color: Colors.white,
borderRadius: BorderRadius.circular(10),
),
margin: EdgeInsets.all(15),
child: TextField(
controller: txt,
autofocus: true,
decoration: InputDecoration(
contentPadding: EdgeInsets.fromLTRB(15, 0, 15, 7),
border: InputBorder.none,
),
),
),
));
}
}
| 0 |
mirrored_repositories/pigeon/lib/widget/devices | mirrored_repositories/pigeon/lib/widget/devices/tv/remote_tv.dart | import 'dart:ui';
import 'package:flutter/material.dart';
import 'package:get/get.dart';
import 'package:pigeon1/widget/devices/tv/search.dart';
import 'package:pigeon1/widget/shadow.dart';
Widget remoteTv({
required double width,
required BuildContext context,
}) {
Widget butt({required Widget widget}) {
return Container(
width: width / 8,
height: width / 8,
decoration: BoxDecoration(
color: Colors.white,
shape: BoxShape.circle,
boxShadow: [
boxShadow,
],
),
child: widget);
}
// openkey() {
// FocusScope.of(context).requestFocus(FocusNode());
// }
return Container(
width: width,
padding: EdgeInsets.all(20),
margin: EdgeInsets.fromLTRB(15, 0, 15, 0),
decoration: BoxDecoration(
color: Colors.white,
borderRadius: BorderRadius.circular(10),
boxShadow: [
boxShadow,
],
),
child: Column(
children: [
Row(
mainAxisAlignment: MainAxisAlignment.spaceBetween,
children: [
butt(
widget: Icon(
Icons.mic_rounded,
),
),
butt(
widget: Icon(Icons.volume_off_rounded),
),
GestureDetector(
onTap: () {
Get.bottomSheet(Search());
},
child: butt(
widget: Icon(
Icons.search_rounded,
),
),
),
// Wrap(
// children: [
// // InkWell(
// // onTap: openkey,
// // child: butt(
// // widget: Padding(
// // padding: const EdgeInsets.all(10),
// // child: Row(
// // mainAxisAlignment: MainAxisAlignment.spaceBetween,
// // children: [
// // for (var i = 1; i < 4; i++)
// // Text(
// // i.toString(),
// // style: TextStyle(
// // fontWeight: FontWeight.bold,
// // ),
// // )
// // ],
// // ),
// // ),
// // ),
// // ),
// SizedBox(
// width: 15,
// ),
// InkWell(
// onTap: openkey,
// child: butt(
// widget: Padding(
// padding: const EdgeInsets.all(10),
// child: Row(
// mainAxisAlignment: MainAxisAlignment.spaceBetween,
// children: [
// for (var i = 'A'.codeUnitAt(0);
// i < 'D'.codeUnitAt(0);
// i++)
// Text(
// String.fromCharCode(i),
// style: TextStyle(
// fontWeight: FontWeight.bold,
// fontSize: 12,
// ),
// )
// ],
// ),
// ),
// ),
// ),
// ],
// ),
],
),
SizedBox(
height: 20,
),
Container(
width: width / 2.3,
height: width / 2.3,
decoration: BoxDecoration(
color: Colors.white,
shape: BoxShape.circle,
boxShadow: [
// boxShadow,
]),
child: Stack(
children: [
Positioned(
top: 0,
left: 0,
right: 0,
bottom: null,
child: butt(
widget: RotatedBox(
quarterTurns: 1,
child: Icon(
Icons.arrow_back_ios_new_rounded,
),
),
),
),
Positioned(
top: 0,
left: null,
right: 0,
bottom: 0,
child: butt(
widget: RotatedBox(
quarterTurns: 2,
child: Icon(
Icons.arrow_back_ios_new_rounded,
),
),
),
),
Positioned(
top: null,
left: 0,
right: 0,
bottom: 0,
child: butt(
widget: RotatedBox(
quarterTurns: 3,
child: Icon(
Icons.arrow_back_ios_new_rounded,
),
),
),
),
Positioned(
top: 0,
left: 0,
right: null,
bottom: 0,
child: butt(
widget: RotatedBox(
quarterTurns: 4,
child: Icon(
Icons.arrow_back_ios_new_rounded,
),
),
),
),
Center(
child: butt(
widget: Center(
child: Text(
"OKE",
style: TextStyle(
fontWeight: FontWeight.bold,
),
),
)),
)
],
),
),
SizedBox(
height: 40,
),
Wrap(
spacing: 20,
runSpacing: 20,
children: [
butt(
widget: Icon(
Icons.arrow_back_rounded,
),
),
butt(
widget: Icon(
Icons.home_filled,
),
),
butt(
widget: Icon(Icons.settings),
)
],
),
],
),
);
}
| 0 |
mirrored_repositories/pigeon/lib/widget/devices | mirrored_repositories/pigeon/lib/widget/devices/wifi/remote_wifi.dart | import 'package:flutter/material.dart';
import 'package:pigeon1/model/modelUserWifi.dart';
import 'package:pigeon1/widget/shadow.dart';
import 'package:pigeon1/widget/textyle.dart';
class RemoteWifi extends StatefulWidget {
const RemoteWifi({Key? key}) : super(key: key);
@override
_RemoteWifiState createState() => _RemoteWifiState();
}
class _RemoteWifiState extends State<RemoteWifi> {
TextEditingController txt =
TextEditingController(text: "QUICK BROWN LAZY DOG");
List<ModelUserWifi> muw = [
ModelUserWifi(
id: 1,
name: "OPPO A3S",
mac: "50:29:f5:dr:dx:di",
ip: "192.168.0.100",
),
ModelUserWifi(
id: 2,
name: "LENOVO IDEAPAD 110",
mac: "50:29:f5:dr:dx:di sjfkjfksfjsfsjfsj",
ip: "192.168.0.101",
),
ModelUserWifi(
id: 3,
name: "IOS 5",
mac: "50:29:f5:dr:dx:di",
ip: "192.168.0.102",
),
ModelUserWifi(
id: 4,
name: "ROG PHONE",
mac: "50:29:f5:dr:dx:di",
ip: "192.168.0.103",
),
ModelUserWifi(
id: 5,
name: "LINUX SERVER",
mac: "50:29:f5:dr:dx:di",
ip: "192.168.0.104",
),
ModelUserWifi(
id: 6,
name: "NGINX",
mac: "50:29:f5:dr:dx:di",
ip: "192.168.0.105",
),
];
bool ob = true;
look() {
setState(() {
ob ? ob = false : ob = true;
});
}
@override
Widget build(BuildContext context) {
double w = MediaQuery.of(context).size.width;
return Container(
margin: EdgeInsets.fromLTRB(15, 0, 15, 0),
padding: EdgeInsets.all(20),
width: w,
decoration: BoxDecoration(
borderRadius: BorderRadius.circular(10),
color: Colors.white,
boxShadow: [
boxShadow,
],
),
child: Column(
crossAxisAlignment: CrossAxisAlignment.start,
children: [
Column(
crossAxisAlignment: CrossAxisAlignment.start,
children: [
Text(
"Password",
style: txt12b07s,
),
SizedBox(
height: 5,
),
Container(
width: w,
height: 40,
decoration: BoxDecoration(
color: Colors.white,
borderRadius: BorderRadius.circular(10),
boxShadow: [
boxShadow,
]),
child: TextField(
controller: txt,
obscureText: ob,
decoration: InputDecoration(
suffixIcon: InkWell(
onTap: look,
child: Icon(
!ob
? Icons.visibility_off_rounded
: Icons.visibility_rounded,
),
),
contentPadding: EdgeInsets.fromLTRB(15, 7, 15, 0),
border: InputBorder.none,
),
),
),
],
),
SizedBox(
height: 20,
),
SizedBox(
width: w,
child: Wrap(
alignment: WrapAlignment.spaceBetween,
children: [
Text(
"User",
style: txt12b07s,
),
Text(
muw.length.toString(),
style: txt12b07s,
),
],
),
),
SizedBox(
height: 5,
),
for (var a in muw)
Container(
padding: EdgeInsets.all(15),
width: w,
margin: EdgeInsets.only(bottom: 20),
decoration: BoxDecoration(
color: Colors.white,
borderRadius: BorderRadius.circular(10),
boxShadow: [
boxShadow,
],
),
child: Wrap(
alignment: WrapAlignment.spaceBetween,
crossAxisAlignment: WrapCrossAlignment.center,
direction: Axis.horizontal,
children: [
Wrap(
direction: Axis.vertical,
children: [
Text(
a.name,
style: txt12b07s,
),
SizedBox(
height: 10,
),
Text(
"MAC: " + a.mac,
style: txt12b07s,
),
SizedBox(
height: 10,
),
Text(
"IP: " + a.ip,
style: txt12b07s,
),
],
),
GestureDetector(
onTap: () {
setState(() {
muw.removeWhere((element) => element.id == a.id);
});
},
child: Container(
width: w / 10,
height: w / 10,
decoration: BoxDecoration(
color: Colors.white,
shape: BoxShape.circle,
boxShadow: [
boxShadow,
]),
child: Icon(
Icons.close_rounded,
color: Colors.red,
),
),
),
],
),
)
],
),
);
}
}
| 0 |
mirrored_repositories/pigeon/lib/widget | mirrored_repositories/pigeon/lib/widget/icon/findIcons.dart | import 'package:flutter/material.dart';
findIcons({required int icon}) {
if (icon == 1) {
return Icons.tv_rounded;
}
if (icon == 2) {
return Icons.wifi_rounded;
}
if (icon == 3) {
return Icons.water_rounded;
}
if (icon == 4) {
return Icons.light_rounded;
}
}
| 0 |
mirrored_repositories/pigeon/lib/widget | mirrored_repositories/pigeon/lib/widget/home/outofusage.dart | import 'package:flutter/material.dart';
import '../shadow.dart';
Widget outOfUsage(double width) {
return Container(
padding: EdgeInsets.fromLTRB(15, 20, 15, 20),
margin: EdgeInsets.fromLTRB(15, 0, 15, 0),
width: width,
decoration: BoxDecoration(
color: Colors.blue,
borderRadius: BorderRadius.circular(10),
boxShadow: [
boxShadow,
]),
child: Align(
alignment: Alignment.center,
child: Wrap(
alignment: WrapAlignment.spaceBetween,
crossAxisAlignment: WrapCrossAlignment.center,
children: [
SizedBox(
width: width / 1.8,
child: Text(
"Tv mu tidak digunakan, matikan segera biar hemat",
style: TextStyle(
color: Colors.white,
fontSize: 13,
height: 1.4,
),
),
),
Container(
margin: EdgeInsets.only(left: 15),
width: 70,
padding: EdgeInsets.fromLTRB(10, 10, 10, 10),
decoration: BoxDecoration(
color: Colors.yellowAccent,
borderRadius: BorderRadius.circular(50),
boxShadow: [
boxShadow,
]),
child: Center(
child: Text(
"Matikan",
style: TextStyle(
color: Colors.black,
fontSize: 13,
fontWeight: FontWeight.bold,
letterSpacing: 0.2,
),
),
),
)
],
),
),
);
}
| 0 |
mirrored_repositories/pigeon/lib/widget | mirrored_repositories/pigeon/lib/widget/home/penggunaan.dart | import 'package:flutter/material.dart';
import '../textyle.dart';
import '../shadow.dart';
Widget penggunaan(double width) {
return Padding(
padding: const EdgeInsets.fromLTRB(15, 0, 15, 0),
child: Column(
children: [
Row(
mainAxisAlignment: MainAxisAlignment.spaceBetween,
children: [
Text(
"Penggunaan",
style: txt15bs,
),
Container(
padding: EdgeInsets.fromLTRB(10, 5, 10, 5),
decoration: BoxDecoration(
color: Colors.white,
borderRadius: BorderRadius.circular(10),
boxShadow: [
boxShadow,
],
),
child: Row(
children: [
Icon(
Icons.date_range_rounded,
size: 20,
color: Colors.blue,
),
SizedBox(
width: 5,
),
Text(
"6 Apr 2021",
style: txt12b07s,
),
],
),
)
],
),
SizedBox(
height: 15,
),
Container(
width: width,
decoration: BoxDecoration(
color: Colors.white,
boxShadow: [
boxShadow,
],
borderRadius: BorderRadius.circular(10),
),
padding: EdgeInsets.all(15),
child: Row(
mainAxisAlignment: MainAxisAlignment.spaceEvenly,
children: [
Row(
children: [
Icon(
Icons.cable_rounded,
color: Colors.blue,
),
SizedBox(
width: 10,
),
Column(
crossAxisAlignment: CrossAxisAlignment.start,
children: [
Text(
"Hari ini",
style: TextStyle(
fontSize: 14,
color: Colors.grey,
),
),
SizedBox(
height: 5,
),
Text(
"28.6 " + "kWh",
style: txt15bs,
),
],
)
],
),
SizedBox(
width: 5,
),
Container(
width: 1,
height: width / 10,
color: Colors.black.withOpacity(0.2),
),
SizedBox(
width: 5,
),
Row(
children: [
Icon(
Icons.bolt_rounded,
color: Colors.pinkAccent,
),
SizedBox(
width: 10,
),
Column(
crossAxisAlignment: CrossAxisAlignment.start,
children: [
Text(
"Bulan ini",
style: TextStyle(
fontSize: 14,
color: Colors.grey,
),
),
SizedBox(
height: 5,
),
Text(
"28.6 " + "kWh",
style: txt15bs,
),
],
)
],
),
],
),
)
],
),
);
}
| 0 |
mirrored_repositories/pigeon/lib/widget | mirrored_repositories/pigeon/lib/widget/home/greeting.dart | import 'package:flutter/material.dart';
import 'package:pigeon1/widget/shadow.dart';
import 'package:pigeon1/widget/textyle.dart';
Widget greeting() {
return SafeArea(
child: StreamBuilder(
stream: Stream.periodic(Duration(hours: 1)).asBroadcastStream(),
builder: (contex, snap) {
String ger = "";
final h = DateTime.now().hour;
if (h >= 0 && h <= 9) {
ger = "Pagi";
}
if (h >= 10 && h <= 14) {
ger = "Siang";
}
if (h >= 15 && h <= 18) {
ger = "Sore";
}
if (h >= 19 && h <= 24) {
ger = "Malam";
}
return Padding(
padding: const EdgeInsets.fromLTRB(15, 15, 15, 0),
child: Row(
mainAxisAlignment: MainAxisAlignment.spaceBetween,
children: [
Column(
crossAxisAlignment: CrossAxisAlignment.start,
children: [
Text(
"Selamat $ger",
style: txt15bs,
),
SizedBox(
height: 2,
),
Text(
"Kendalikan rumah dengan mudah",
style: txt12b07s,
)
],
),
Container(
width: 30,
height: 30,
decoration: BoxDecoration(
color: Colors.white,
shape: BoxShape.circle,
boxShadow: [
boxShadow,
]),
child: Icon(
Icons.person_rounded,
),
)
],
),
);
},
),
);
}
| 0 |
mirrored_repositories/pigeon/lib | mirrored_repositories/pigeon/lib/controller/devices_controller.dart | import 'package:get/get.dart';
import 'package:pigeon1/model/modeldevices.dart';
class DevicesController extends GetxController {
List<ModelDevices> dataDevices = [
ModelDevices(
id: 1,
icon: 1,
name: "Televisi",
konsumsi: 45.5,
use: DateTime(2021, 8, 26, 12),
active: false,
),
ModelDevices(
id: 2,
icon: 2,
name: "Wifi",
konsumsi: 15.5,
use: DateTime(2021, 1, 1, 18),
active: true,
),
ModelDevices(
id: 3,
icon: 3,
name: "Pompa air",
konsumsi: 64.2,
use: DateTime(2021, 8, 26, 4),
active: false,
),
ModelDevices(
id: 4,
icon: 4,
name: "Lampu depan",
konsumsi: 8,
use: DateTime(2021, 8, 25, 15),
active: true,
),
ModelDevices(
id: 5,
icon: 4,
name: "Lampu ruang tamu",
konsumsi: 8,
use: DateTime(2021, 8, 25, 15),
active: true,
),
ModelDevices(
id: 6,
icon: 4,
name: "Lampu ruang keluarga",
konsumsi: 8,
use: DateTime(2021, 8, 25, 15),
active: true,
),
ModelDevices(
id: 7,
icon: 4,
name: "Lampu dapur",
konsumsi: 8,
use: DateTime(2021, 8, 25, 15),
active: true,
),
ModelDevices(
id: 8,
icon: 4,
name: "Lampu kamar mandi",
konsumsi: 8,
use: DateTime(2021, 8, 25, 15),
active: true,
),
];
updateActive(
{required bool active, required int id, required DateTime dateTime}) {
var q = dataDevices.where((element) => id == element.id).first;
q.active = active;
!active ? q.use = DateTime(0, 0, 0, 0, 0) : q.use = dateTime;
update();
print(q.id);
print(q.active);
}
}
| 0 |
mirrored_repositories/pigeon | mirrored_repositories/pigeon/test/widget_test.dart | // This is a basic Flutter widget test.
//
// To perform an interaction with a widget in your test, use the WidgetTester
// utility that Flutter provides. For example, you can send tap and scroll
// gestures. You can also use WidgetTester to find child widgets in the widget
// tree, read text, and verify that the values of widget properties are correct.
import 'package:flutter/material.dart';
import 'package:flutter_test/flutter_test.dart';
import 'package:pigeon1/main.dart';
void main() {
testWidgets('Counter increments smoke test', (WidgetTester tester) async {
// Build our app and trigger a frame.
await tester.pumpWidget(MyApp());
// Verify that our counter starts at 0.
expect(find.text('0'), findsOneWidget);
expect(find.text('1'), findsNothing);
// Tap the '+' icon and trigger a frame.
await tester.tap(find.byIcon(Icons.add));
await tester.pump();
// Verify that our counter has incremented.
expect(find.text('0'), findsNothing);
expect(find.text('1'), findsOneWidget);
});
}
| 0 |
mirrored_repositories/flutter_ui_concept_solor_system | mirrored_repositories/flutter_ui_concept_solor_system/lib/colors.dart | import 'dart:ui';
const god_gray = Color(0xFF151515);
const burnt_sienna = Color(0xFFEF5F53);
const salmon = Color(0xFFFA8F70);
const electric_violet = Color(0xFF5935FF);
const victoria = Color(0xFF47408E);
const hot_pink = Color(0xFFFF6CD9);
const wild_strawberry = Color(0xFFFF2184);
const robin_blue = Color(0xFF01D4E4);
const cerulean = Color(0xFF009DE0);
const rajah = Color(0xFFF9C270);
const sunshade = Color(0xFFFFAA2B);
const white_65 = Color(0xA6FFFFFF);
const gray_75 = Color(0xBF151515);
const orange_peel = Color(0xFFA000);
| 0 |
mirrored_repositories/flutter_ui_concept_solor_system | mirrored_repositories/flutter_ui_concept_solor_system/lib/main.dart | import 'package:flutter/material.dart';
import 'package:flutter_ui_concept_solar_system/colors.dart';
import 'package:flutter_ui_concept_solar_system/screens/bookmark.dart';
import 'package:flutter_ui_concept_solar_system/screens/detail.dart';
import 'package:flutter_ui_concept_solar_system/screens/gallery.dart';
import 'package:flutter_ui_concept_solar_system/screens/home.dart';
import 'package:flutter_ui_concept_solar_system/screens/home_screen.dart';
import 'package:flutter_ui_concept_solar_system/screens/search.dart';
import 'package:flutter_ui_concept_solar_system/screens/welcome.dart';
void main() {
runApp(MyApp());
}
class MyApp extends StatelessWidget {
// This widget is the root of your application.
@override
Widget build(BuildContext context) {
return MaterialApp(
title: 'Solar System',
debugShowCheckedModeBanner: false,
theme: ThemeData(
primarySwatch: Colors.blue,
primaryColor: god_gray,
backgroundColor: god_gray,
visualDensity: VisualDensity.adaptivePlatformDensity,
),
home: WelcomeScreen(),
routes: {
'/welcome': (context) => WelcomeScreen(),
'/home': (context) => HomePage(),
'/home_screen': (context) => HomeScreen(),
'/search': (context) => SearchScreen(),
'/detail': (context) => DetailPage(),
'/bookmark': (context) => BookmarkScreen(),
'/gallery': (context) => GalleryPage()
},
);
}
}
| 0 |
mirrored_repositories/flutter_ui_concept_solor_system/lib | mirrored_repositories/flutter_ui_concept_solor_system/lib/widgets/search_box.dart | import 'package:flutter/material.dart';
import 'package:flutter_ui_concept_solar_system/colors.dart';
class SearchBox extends StatefulWidget {
final TextEditingController controller;
final String hint;
final bool enable;
SearchBox({this.controller, this.hint, this.enable});
@override
_SearchBoxState createState() => _SearchBoxState();
}
class _SearchBoxState extends State<SearchBox> {
@override
Widget build(BuildContext context) {
return Container(
margin: EdgeInsets.symmetric(horizontal: 24, vertical: 12),
decoration: BoxDecoration(
color: god_gray,
borderRadius: BorderRadius.all(Radius.circular(8.0))),
child: TextField(
enabled: widget.enable,
controller: widget.controller,
style: TextStyle(color: Colors.white),
decoration: InputDecoration(
hintText: widget.hint,
hintStyle: TextStyle(color: white_65),
prefixIcon: Icon(
Icons.search,
color: Colors.white,
),
fillColor: god_gray,
enabledBorder: OutlineInputBorder(
borderRadius: BorderRadius.all(Radius.circular(8.0))),
focusedBorder: OutlineInputBorder(
borderRadius: BorderRadius.all(Radius.circular(8.0))),
disabledBorder: OutlineInputBorder(
borderRadius: BorderRadius.all(Radius.circular(8.0))),
border: OutlineInputBorder(
borderRadius: BorderRadius.all(Radius.circular(8.0)))),
),
);
}
}
| 0 |
mirrored_repositories/flutter_ui_concept_solor_system/lib | mirrored_repositories/flutter_ui_concept_solor_system/lib/widgets/gradient_button.dart | import 'package:flutter/material.dart';
class GradientButton extends StatefulWidget {
final String text;
final Gradient gradient;
final VoidCallback onTap;
GradientButton({this.gradient, this.onTap, this.text});
@override
_GradientButtonState createState() => _GradientButtonState();
}
class _GradientButtonState extends State<GradientButton> {
@override
Widget build(BuildContext context) {
return InkWell(
onTap: widget.onTap,
child: Container(
padding: EdgeInsets.all(16),
width: 300,
child: Row(
mainAxisAlignment: MainAxisAlignment.center,
children: [
Text(
widget.text,
textAlign: TextAlign.center,
style: TextStyle(
color: Colors.white,
fontSize: 16,
fontWeight: FontWeight.bold),
),
SizedBox(
width: 24,
),
Icon(
Icons.arrow_forward,
color: Colors.white,
)
],
),
decoration: BoxDecoration(
gradient: widget.gradient,
borderRadius: BorderRadius.all(Radius.circular(16))),
),
);
}
}
| 0 |
mirrored_repositories/flutter_ui_concept_solor_system/lib | mirrored_repositories/flutter_ui_concept_solor_system/lib/widgets/custom_appbar.dart | import 'package:flutter/material.dart';
class CustomAppBar extends PreferredSize {
final double height;
final Widget child;
const CustomAppBar({this.height, this.child});
@override
Size get preferredSize => Size.fromHeight(height);
@override
Widget build(BuildContext context) {
return Container(
child: child,
height: preferredSize.height,
);
}
}
| 0 |
mirrored_repositories/flutter_ui_concept_solor_system/lib | mirrored_repositories/flutter_ui_concept_solor_system/lib/widgets/custom_text.dart | import 'package:flutter/material.dart';
class CustomText extends StatelessWidget {
final String text;
final double size;
final Color color;
final int maxLines;
const CustomText({this.text, this.color, this.size, this.maxLines});
@override
Widget build(BuildContext context) {
return Text(
text,
overflow: TextOverflow.ellipsis,
maxLines: maxLines,
style:
TextStyle(fontWeight: FontWeight.bold, color: color, fontSize: size),
);
}
}
| 0 |
mirrored_repositories/flutter_ui_concept_solor_system/lib | mirrored_repositories/flutter_ui_concept_solor_system/lib/data/detail.dart | class Detail {
final String text;
final String detail;
Detail({this.text, this.detail});
}
| 0 |
mirrored_repositories/flutter_ui_concept_solor_system/lib | mirrored_repositories/flutter_ui_concept_solor_system/lib/data/category.dart | import 'dart:ui';
class Category {
final String iconPath;
final String title;
final Color colorOne;
final Color colorTwo;
Category({this.iconPath, this.title, this.colorOne, this.colorTwo});
}
| 0 |
mirrored_repositories/flutter_ui_concept_solor_system/lib | mirrored_repositories/flutter_ui_concept_solor_system/lib/data/planet.dart | import 'package:flutter/material.dart';
class Planet {
final int id;
final String iconPath;
final String title;
final Color color;
Planet({this.iconPath, this.title, this.color, this.id});
}
| 0 |
mirrored_repositories/flutter_ui_concept_solor_system/lib | mirrored_repositories/flutter_ui_concept_solor_system/lib/screens/bookmark.dart | import 'package:flutter/material.dart';
import 'package:flutter_svg/flutter_svg.dart';
import 'package:flutter_ui_concept_solar_system/colors.dart';
import 'package:flutter_ui_concept_solar_system/data/planet.dart';
import 'package:flutter_ui_concept_solar_system/widgets/custom_appbar.dart';
import 'package:flutter_ui_concept_solar_system/widgets/custom_text.dart';
import 'detail.dart';
class BookmarkScreen extends StatefulWidget {
const BookmarkScreen({Key key}) : super(key: key);
@override
_BookmarkScreenState createState() => _BookmarkScreenState();
}
class _BookmarkScreenState extends State<BookmarkScreen> {
List<Planet> planets = [];
@override
void initState() {
super.initState();
planets.add(Planet(
id: 1,
iconPath: "assets/planets/Earth.svg",
title: "Sol",
color: electric_violet));
planets.add(Planet(
id: 2,
iconPath: "assets/planets/Jupiter.svg",
title: "Mercú",
color: electric_violet));
planets.add(Planet(
id: 3,
iconPath: "assets/planets/Mars.svg",
title: "Vênus",
color: electric_violet));
planets.add(Planet(
id: 4,
iconPath: "assets/planets/Mercury.svg",
title: "Terra",
color: electric_violet));
planets.add(Planet(
id: 5,
iconPath: "assets/planets/Neptune.svg",
title: "Marte",
color: electric_violet));
planets.add(Planet(
id: 6,
iconPath: "assets/planets/Pluto.svg",
title: "Júpiter",
color: electric_violet));
planets.add(Planet(
id: 7,
iconPath: "assets/planets/Saturn.svg",
title: "Saturno",
color: electric_violet));
planets.add(Planet(
id: 8,
iconPath: "assets/planets/Sun.svg",
title: "Urânio",
color: electric_violet));
planets.add(Planet(
id: 9,
iconPath: "assets/planets/Uranus.svg",
title: "Netuno",
color: electric_violet));
planets.add(Planet(
id: 10,
iconPath: "assets/planets/Venus.svg",
title: "Plutão",
color: electric_violet));
}
@override
Widget build(BuildContext context) {
return Scaffold(
backgroundColor: Colors.black,
appBar: CustomAppBar(
child: Column(
crossAxisAlignment: CrossAxisAlignment.start,
children: [
SizedBox(
height: 40,
),
SizedBox(
height: 20,
),
Padding(
padding: const EdgeInsets.only(left: 24.0, right: 20),
child: Text(
"Saved",
maxLines: 1,
overflow: TextOverflow.ellipsis,
style: TextStyle(
color: Colors.white,
fontWeight: FontWeight.bold,
fontSize: 32),
),
)
],
),
height: 120,
),
body: ListView.builder(
padding: EdgeInsets.symmetric(horizontal: 24),
itemBuilder: (BuildContext context, int index) {
return GestureDetector(
onTap: () {
Navigator.push(
context,
MaterialPageRoute(
builder: (context) => DetailPage(
planet: planets[index],
),
));
},
child: Padding(
padding: const EdgeInsets.only(bottom: 16.0),
child: ClipRRect(
borderRadius: BorderRadius.circular(8),
child: Container(
height: MediaQuery.of(context).size.height * 0.25,
decoration: BoxDecoration(
color: god_gray,
borderRadius: BorderRadius.all(Radius.circular(8))),
child: Stack(
children: [
Positioned(
left: -50,
top: -30,
child: Hero(
tag: planets[index].id,
child: SvgPicture.asset(
planets[index].iconPath,
width: MediaQuery.of(context).size.width * 0.2,
height: MediaQuery.of(context).size.height * 0.25,
)),
),
Padding(
padding: const EdgeInsets.all(16.0),
child: Row(
children: [
Expanded(
flex: 1,
child: SizedBox(),
),
Expanded(
flex: 1,
child: Column(
children: [
Row(
mainAxisAlignment:
MainAxisAlignment.spaceBetween,
children: [
CustomText(
text: planets[index].title,
maxLines: 1,
size: 32,
color: Colors.white,
),
Icon(Icons.bookmark, color: salmon)
],
),
Padding(padding: EdgeInsets.all(8)),
CustomText(
size: 14,
color: white_65,
maxLines: 4,
text:
"Netuno é o oitavo planeta do Sistema Solar, o último a partir do Sol desde a reclassificação...",
),
Padding(padding: EdgeInsets.all(8)),
Row(
children: [
CustomText(
size: 14,
color: Colors.white,
maxLines: 1,
text: "Continue lendo",
),
SizedBox(
width: 10,
),
Icon(
Icons.arrow_forward,
color: salmon,
)
],
)
],
),
)
],
),
),
],
),
),
),
),
);
},
itemCount: planets.length,
),
);
}
}
| 0 |
mirrored_repositories/flutter_ui_concept_solor_system/lib | mirrored_repositories/flutter_ui_concept_solor_system/lib/screens/home_screen.dart | import 'package:flutter/material.dart';
import 'package:flutter_svg/flutter_svg.dart';
import 'package:flutter_ui_concept_solar_system/data/category.dart';
import 'package:flutter_ui_concept_solar_system/data/planet.dart';
import 'package:flutter_ui_concept_solar_system/screens/detail.dart';
import 'package:flutter_ui_concept_solar_system/widgets/custom_appbar.dart';
import 'package:flutter_ui_concept_solar_system/widgets/search_box.dart';
import '../colors.dart';
class HomeScreen extends StatefulWidget {
HomeScreen({Key key}) : super(key: key);
@override
_HomeScreenState createState() => _HomeScreenState();
}
class _HomeScreenState extends State<HomeScreen> {
TextEditingController controller = TextEditingController();
List<Category> categories = [];
List<Planet> planets = [];
@override
void initState() {
super.initState();
categories.add(Category(
iconPath: "assets/icons/planet.svg",
title: "Planetas",
colorOne: electric_violet,
colorTwo: victoria));
categories.add(Category(
iconPath: "assets/icons/astroid.svg",
title: "Asteróides",
colorOne: hot_pink,
colorTwo: wild_strawberry));
categories.add(Category(
iconPath: "assets/icons/star.svg",
title: "Estrelas",
colorOne: robin_blue,
colorTwo: cerulean));
categories.add(Category(
iconPath: "assets/icons/galaxy.svg",
title: "Galáxias",
colorOne: rajah,
colorTwo: sunshade));
planets.add(Planet(
id: 1,
iconPath: "assets/planets/Earth.svg",
title: "Sol",
color: electric_violet));
planets.add(Planet(
id: 2,
iconPath: "assets/planets/Jupiter.svg",
title: "Mercúrio",
color: electric_violet));
planets.add(Planet(
id: 3,
iconPath: "assets/planets/Mars.svg",
title: "Vênus",
color: electric_violet));
planets.add(Planet(
id: 4,
iconPath: "assets/planets/Mercury.svg",
title: "Terra",
color: electric_violet));
planets.add(Planet(
id: 5,
iconPath: "assets/planets/Neptune.svg",
title: "Marte",
color: electric_violet));
planets.add(Planet(
id: 6,
iconPath: "assets/planets/Pluto.svg",
title: "Júpiter",
color: electric_violet));
planets.add(Planet(
id: 7,
iconPath: "assets/planets/Saturn.svg",
title: "Saturno",
color: electric_violet));
planets.add(Planet(
id: 8,
iconPath: "assets/planets/Sun.svg",
title: "Urânio",
color: electric_violet));
planets.add(Planet(
id: 9,
iconPath: "assets/planets/Uranus.svg",
title: "Netuno",
color: electric_violet));
planets.add(Planet(
id: 10,
iconPath: "assets/planets/Venus.svg",
title: "Plutão",
color: electric_violet));
}
@override
Widget build(BuildContext context) {
return Scaffold(
backgroundColor: Colors.black,
appBar: CustomAppBar(
child: Column(
crossAxisAlignment: CrossAxisAlignment.start,
children: [
SizedBox(
height: 60,
),
Padding(
padding: const EdgeInsets.only(left: 24.0, right: 20),
child: Row(
mainAxisAlignment: MainAxisAlignment.spaceBetween,
children: [
RichText(
text: TextSpan(
children: <TextSpan>[
TextSpan(
text: 'Olá, ',
style: TextStyle(
color: Colors.white,
fontSize: 36,
fontWeight: FontWeight.bold),
),
TextSpan(
text: 'Ana Cecília',
style: TextStyle(
color: wild_strawberry,
fontSize: 36,
fontWeight: FontWeight.bold),
),
],
),
),
Icon(
Icons.settings,
size: 24,
color: Colors.white,
)
],
),
),
Padding(
padding: const EdgeInsets.only(left: 24.0, right: 20),
child: Text(
"O que você vai aprender hoje?",
style: TextStyle(color: Colors.white, fontSize: 16),
),
)
],
),
height: 140,
),
body: SingleChildScrollView(
child: Column(
children: [
GestureDetector(
onTap: () {
Navigator.pushNamed(context, "/search");
},
child: SearchBox(
enable: false,
controller: controller,
hint: "Procure planetas, asteroides, estrelas...",
),
),
SizedBox(
height: 20,
),
Align(
alignment: Alignment.centerLeft,
child: Padding(
padding: const EdgeInsets.only(left: 24.0),
child: Text(
"Categories",
style: TextStyle(color: Colors.white, fontSize: 16),
),
),
),
SizedBox(
height: 20,
),
Container(
height: MediaQuery.of(context).size.height * 0.15,
child: ListView.builder(
padding: const EdgeInsets.only(left: 24.0),
itemBuilder: (BuildContext context, int index) {
return Container(
height: MediaQuery.of(context).size.height * 0.15,
width: MediaQuery.of(context).size.height * 0.15,
margin: EdgeInsets.only(top: 8, right: 16, bottom: 8),
padding: EdgeInsets.all(8),
decoration: BoxDecoration(
gradient: LinearGradient(
colors: <Color>[
categories[index].colorOne,
categories[index].colorTwo
],
),
borderRadius: BorderRadius.all(Radius.circular(8))),
child: Column(
mainAxisSize: MainAxisSize.min,
mainAxisAlignment: MainAxisAlignment.center,
children: [
SvgPicture.asset(
categories[index].iconPath,
),
SizedBox(
height: 10,
),
Text(
categories[index].title,
style: TextStyle(color: Colors.white, fontSize: 14),
)
],
),
);
},
itemCount: categories.length,
scrollDirection: Axis.horizontal,
),
),
SizedBox(
height: 20,
),
Align(
alignment: Alignment.centerLeft,
child: Padding(
padding: const EdgeInsets.only(left: 24.0),
child: Text(
"Planetas",
style: TextStyle(color: Colors.white, fontSize: 16),
),
),
),
SizedBox(
height: 20,
),
Container(
height: MediaQuery.of(context).size.height * 0.3,
child: ListView.builder(
padding: const EdgeInsets.only(left: 24.0),
itemBuilder: (BuildContext context, int index) {
return GestureDetector(
onTap: () {
Navigator.push(
context,
MaterialPageRoute(
builder: (context) => DetailPage(
planet: planets[index],
),
));
},
child: Padding(
padding: const EdgeInsets.only(
top: 8.0, bottom: 8.0, right: 16.0),
child: ClipRRect(
borderRadius: BorderRadius.circular(8),
child: Container(
height: MediaQuery.of(context).size.height * 0.3,
width: MediaQuery.of(context).size.height * 0.2,
decoration: BoxDecoration(
color: god_gray,
borderRadius: BorderRadius.only(
topLeft: Radius.circular(0),
topRight: Radius.circular(0),
bottomLeft: Radius.circular(0),
bottomRight: Radius.circular(0))),
child: Stack(
children: [
Positioned(
left: -50,
top: -30,
child: Hero(
tag: planets[index].id,
child: SvgPicture.asset(
planets[index].iconPath,
width: MediaQuery.of(context).size.width *
0.15,
height: MediaQuery.of(context).size.height *
0.23,
),
),
),
Positioned(
bottom: 20,
left: 20,
right: 20,
child: Row(
mainAxisAlignment:
MainAxisAlignment.spaceBetween,
children: [
Text(
planets[index].title,
style: TextStyle(
color: Colors.white,
fontSize: 16,
fontWeight: FontWeight.bold),
),
Icon(
Icons.arrow_forward,
color: salmon,
)
],
),
)
],
),
),
),
),
);
},
itemCount: planets.length,
scrollDirection: Axis.horizontal,
),
),
],
),
),
);
}
}
| 0 |
mirrored_repositories/flutter_ui_concept_solor_system/lib | mirrored_repositories/flutter_ui_concept_solor_system/lib/screens/detail.dart | import 'package:flutter/material.dart';
import 'package:flutter_svg/flutter_svg.dart';
import 'package:flutter_ui_concept_solar_system/colors.dart';
import 'package:flutter_ui_concept_solar_system/data/detail.dart';
import 'package:flutter_ui_concept_solar_system/data/planet.dart';
import 'package:flutter_ui_concept_solar_system/widgets/custom_text.dart';
class DetailPage extends StatefulWidget {
final Planet planet;
const DetailPage({this.planet});
@override
_DetailPageState createState() => _DetailPageState();
}
class _DetailPageState extends State<DetailPage> {
List<Detail> details = [];
@override
void initState() {
details.add(Detail(
text: "Introdução",
detail:
"Marte é o quarto planeta a partir do Sol, o segundo menor do Sistema Solar. Batizado em homenagem ao deus romano da guerra, muitas vezes é descrito como o , porque o óxido de ferro predominante em sua superfície lhe dá uma aparência avermelhada."));
details.add(Detail(
text: "Características Físicas",
detail:
"Marte é o quarto planeta a partir do Sol, o segundo menor do Sistema Solar. Batizado em homenagem ao deus romano da guerra, muitas vezes é descrito como o , porque o óxido de ferro predominante em sua superfície lhe dá uma aparência avermelhada."));
details.add(Detail(
text: "Hidrologia",
detail:
"Marte é o quarto planeta a partir do Sol, o segundo menor do Sistema Solar. Batizado em homenagem ao deus romano da guerra, muitas vezes é descrito como o , porque o óxido de ferro predominante em sua superfície lhe dá uma aparência avermelhada."));
details.add(Detail(
text: "Geografia",
detail:
"Marte é o quarto planeta a partir do Sol, o segundo menor do Sistema Solar. Batizado em homenagem ao deus romano da guerra, muitas vezes é descrito como o , porque o óxido de ferro predominante em sua superfície lhe dá uma aparência avermelhada."));
details.add(Detail(
text: "More",
detail:
"Marte é o quarto planeta a partir do Sol, o segundo menor do Sistema Solar. Batizado em homenagem ao deus romano da guerra, muitas vezes é descrito como o , porque o óxido de ferro predominante em sua superfície lhe dá uma aparência avermelhada."));
super.initState();
}
@override
Widget build(BuildContext context) {
return Scaffold(
body: Column(
children: [
Header(planet: widget.planet),
Title(planet: widget.planet),
Flexible(
child: Content(
details: details,
))
],
),
);
}
}
class Header extends StatelessWidget {
final Planet planet;
const Header({this.planet});
@override
Widget build(BuildContext context) {
return Container(
height: MediaQuery.of(context).size.height * 0.4,
child: Stack(
children: [
Container(
height: MediaQuery.of(context).size.height * 0.35,
decoration: BoxDecoration(
color: god_gray,
borderRadius: BorderRadius.only(
bottomLeft: Radius.circular(32),
bottomRight: Radius.circular(32),
),
),
),
Positioned(
bottom: 0,
left: 0,
right: 0,
child: Hero(
tag: planet.id,
child: SvgPicture.asset(
planet.iconPath,
width: MediaQuery.of(context).size.height * 0.3,
))),
Positioned(
left: 20,
top: 60,
child: Icon(Icons.arrow_back, color: Colors.white)),
Positioned(
right: 20,
top: 60,
child: Icon(Icons.settings, color: Colors.white)),
],
),
);
}
}
class Title extends StatelessWidget {
final Planet planet;
const Title({this.planet});
@override
Widget build(BuildContext context) {
return Column(
children: [
Padding(
padding: const EdgeInsets.all(24.0),
child: Row(
children: [
Expanded(
flex: 4,
child: CustomText(
text: planet.title,
color: god_gray,
maxLines: 1,
size: 32,
),
),
Expanded(
flex: 1,
child: Row(
children: [
Icon(
Icons.bookmark_border,
color: god_gray,
),
SizedBox(
width: 20,
),
Icon(
Icons.share,
color: god_gray,
),
],
),
),
],
),
),
Padding(
padding: const EdgeInsets.symmetric(horizontal: 24.0),
child: CustomText(
text:
"Marte é o quarto planeta a partir do Sol, o segundo menor do Sistema Solar. Batizado em homenagem ao deus romano da guerra, muitas vezes é descrito como o , porque o óxido de ferro predominante em sua superfície lhe dá uma aparência avermelhada.",
color: gray_75,
size: 16,
maxLines: 5,
),
)
],
);
}
}
class Content extends StatelessWidget {
final List<Detail> details;
Content({this.details});
@override
Widget build(BuildContext context) {
return ListView.builder(
padding: EdgeInsets.symmetric(vertical: 16, horizontal: 12),
itemCount: details.length,
itemBuilder: (BuildContext context, int index) {
return ExpansionTile(
title: CustomText(
color: Colors.black,
size: 16,
maxLines: 1,
text: details[index].text,
),
initiallyExpanded: false,
children: [
Padding(
padding:
const EdgeInsets.symmetric(horizontal: 12, vertical: 12),
child: CustomText(
text: details[index].detail,
color: gray_75,
maxLines: 5,
size: 16,
),
)
],
);
});
}
}
| 0 |
mirrored_repositories/flutter_ui_concept_solor_system/lib | mirrored_repositories/flutter_ui_concept_solor_system/lib/screens/gallery.dart | import 'package:flutter/material.dart';
import 'package:flutter_svg/flutter_svg.dart';
import 'package:flutter_ui_concept_solar_system/colors.dart';
import 'package:flutter_ui_concept_solar_system/data/planet.dart';
import 'package:flutter_ui_concept_solar_system/widgets/custom_appbar.dart';
import 'package:flutter_ui_concept_solar_system/widgets/custom_text.dart';
import 'detail.dart';
class GalleryPage extends StatefulWidget {
const GalleryPage({Key key}) : super(key: key);
@override
_GalleryPageState createState() => _GalleryPageState();
}
class _GalleryPageState extends State<GalleryPage> {
List<Planet> planets = [];
@override
void initState() {
super.initState();
planets.add(Planet(
id: 1,
iconPath: "assets/planets/Earth.svg",
title: "Sol",
color: electric_violet));
planets.add(Planet(
id: 2,
iconPath: "assets/planets/Jupiter.svg",
title: "Mercú",
color: electric_violet));
planets.add(Planet(
id: 3,
iconPath: "assets/planets/Mars.svg",
title: "Vênus",
color: electric_violet));
planets.add(Planet(
id: 4,
iconPath: "assets/planets/Mercury.svg",
title: "Terra",
color: electric_violet));
planets.add(Planet(
id: 5,
iconPath: "assets/planets/Neptune.svg",
title: "Marte",
color: electric_violet));
planets.add(Planet(
id: 6,
iconPath: "assets/planets/Pluto.svg",
title: "Júpiter",
color: electric_violet));
planets.add(Planet(
id: 7,
iconPath: "assets/planets/Uranus.svg",
title: "Netuno",
color: electric_violet));
planets.add(Planet(
id: 8,
iconPath: "assets/planets/Sun.svg",
title: "Urânio",
color: electric_violet));
planets.add(Planet(
id: 9,
iconPath: "assets/planets/Venus.svg",
title: "Plutão",
color: electric_violet));
planets.add(Planet(
id: 10,
iconPath: "assets/planets/Uranus.svg",
title: "Netuno",
color: electric_violet));
}
@override
Widget build(BuildContext context) {
return Scaffold(
backgroundColor: Colors.black,
appBar: CustomAppBar(
child: Column(
crossAxisAlignment: CrossAxisAlignment.start,
children: [
SizedBox(
height: 40,
),
SizedBox(
height: 20,
),
Padding(
padding: const EdgeInsets.only(left: 24.0, right: 20),
child: Text(
"Planetas",
maxLines: 1,
overflow: TextOverflow.ellipsis,
style: TextStyle(
color: Colors.white,
fontWeight: FontWeight.bold,
fontSize: 32),
),
)
],
),
height: 120,
),
body: GridView.builder(
gridDelegate: SliverGridDelegateWithFixedCrossAxisCount(
childAspectRatio: 2 / 2.8,
crossAxisCount: 2,
crossAxisSpacing: 10,
mainAxisSpacing: 16),
padding: EdgeInsets.all(24),
itemBuilder: (BuildContext context, int index) {
return GestureDetector(
onTap: () {
Navigator.push(
context,
MaterialPageRoute(
builder: (context) => DetailPage(
planet: planets[index],
),
));
},
child: ClipRRect(
borderRadius: BorderRadius.circular(8),
child: Container(
height: MediaQuery.of(context).size.height * 0.3,
width: MediaQuery.of(context).size.height * 0.2,
decoration: BoxDecoration(
color: god_gray,
borderRadius: BorderRadius.only(
topLeft: Radius.circular(0),
topRight: Radius.circular(0),
bottomLeft: Radius.circular(0),
bottomRight: Radius.circular(0))),
child: Stack(
children: [
Positioned(
left: -50,
top: -30,
child: Hero(
tag: planets[index].id,
child: SvgPicture.asset(
planets[index].iconPath,
width: MediaQuery.of(context).size.width * 0.15,
height: MediaQuery.of(context).size.height * 0.23,
),
),
),
Positioned(
bottom: 20,
left: 20,
right: 20,
child: Row(
mainAxisAlignment: MainAxisAlignment.spaceBetween,
children: [
Text(
planets[index].title,
style: TextStyle(
color: Colors.white,
fontSize: 16,
fontWeight: FontWeight.bold),
),
Icon(
Icons.arrow_forward,
color: salmon,
)
],
),
)
],
),
),
),
);
},
itemCount: planets.length,
),
);
}
}
| 0 |
mirrored_repositories/flutter_ui_concept_solor_system/lib | mirrored_repositories/flutter_ui_concept_solor_system/lib/screens/welcome.dart | import 'package:flutter/material.dart';
import 'package:flutter_ui_concept_solar_system/colors.dart';
import 'package:flutter_ui_concept_solar_system/widgets/gradient_button.dart';
class WelcomeScreen extends StatefulWidget {
WelcomeScreen({Key key}) : super(key: key);
@override
_WelcomeScreenState createState() => _WelcomeScreenState();
}
class _WelcomeScreenState extends State<WelcomeScreen> {
@override
Widget build(BuildContext context) {
return Scaffold(
body: Container(
decoration: BoxDecoration(
color: god_gray,
image: DecorationImage(
image: AssetImage("assets/images/bg_welcome.png"),
fit: BoxFit.fill)),
child: Stack(
children: [
Image.asset(
"assets/images/Stars.png",
color: god_gray,
),
Column(
mainAxisAlignment: MainAxisAlignment.spaceBetween,
crossAxisAlignment: CrossAxisAlignment.center,
children: [
SizedBox(
height: 100,
),
Padding(
padding: const EdgeInsets.all(8.0),
child: Column(
crossAxisAlignment: CrossAxisAlignment.center,
mainAxisSize: MainAxisSize.min,
children: [
Text(
"Aperte o cinto",
textAlign: TextAlign.center,
style: TextStyle(
fontSize: 16,
color: Colors.white,
fontWeight: FontWeight.normal),
),
Text(
"Comece sua jornada pelo sistema solar.",
textAlign: TextAlign.center,
style: TextStyle(
fontSize: 32,
color: Colors.white,
fontWeight: FontWeight.bold),
)
],
),
),
Padding(
padding: const EdgeInsets.all(24.0),
child: Column(
mainAxisSize: MainAxisSize.min,
children: [
Text(
"Aperte o cinto",
style: TextStyle(
fontSize: 14,
color: Colors.white,
fontWeight: FontWeight.normal),
),
Padding(padding: EdgeInsets.all(10)),
GradientButton(
text: "fasfa asdfasf asfda",
gradient: LinearGradient(
colors: <Color>[burnt_sienna, salmon],
),
onTap: () {
Navigator.pushReplacementNamed(context, "/home");
},
)
],
),
),
],
),
],
),
),
);
}
}
| 0 |
mirrored_repositories/flutter_ui_concept_solor_system/lib | mirrored_repositories/flutter_ui_concept_solor_system/lib/screens/search.dart | import 'package:flutter/material.dart';
import 'package:flutter_svg/flutter_svg.dart';
import 'package:flutter_ui_concept_solar_system/colors.dart';
import 'package:flutter_ui_concept_solar_system/data/planet.dart';
import 'package:flutter_ui_concept_solar_system/widgets/custom_appbar.dart';
import 'package:flutter_ui_concept_solar_system/widgets/custom_text.dart';
import 'package:flutter_ui_concept_solar_system/widgets/search_box.dart';
import 'detail.dart';
class SearchScreen extends StatefulWidget {
const SearchScreen({Key key}) : super(key: key);
@override
_SearchScreenState createState() => _SearchScreenState();
}
class _SearchScreenState extends State<SearchScreen> {
TextEditingController controller = TextEditingController();
List<Planet> planets = [];
@override
void initState() {
super.initState();
planets.add(Planet(
id: 1,
iconPath: "assets/planets/Earth.svg",
title: "Sol",
color: electric_violet));
planets.add(Planet(
id: 2,
iconPath: "assets/planets/Jupiter.svg",
title: "Mercú",
color: electric_violet));
planets.add(Planet(
id: 3,
iconPath: "assets/planets/Mars.svg",
title: "Vênus",
color: electric_violet));
planets.add(Planet(
id: 4,
iconPath: "assets/planets/Mercury.svg",
title: "Terra",
color: electric_violet));
planets.add(Planet(
id: 5,
iconPath: "assets/planets/Neptune.svg",
title: "Marte",
color: electric_violet));
planets.add(Planet(
id: 6,
iconPath: "assets/planets/Pluto.svg",
title: "Júpiter",
color: electric_violet));
planets.add(Planet(
id: 7,
iconPath: "assets/planets/Saturn.svg",
title: "Saturno",
color: electric_violet));
planets.add(Planet(
id: 8,
iconPath: "assets/planets/Sun.svg",
title: "Urânio",
color: electric_violet));
planets.add(Planet(
id: 9,
iconPath: "assets/planets/Uranus.svg",
title: "Netuno",
color: electric_violet));
planets.add(Planet(
id: 10,
iconPath: "assets/planets/Venus.svg",
title: "Plutão",
color: electric_violet));
}
@override
Widget build(BuildContext context) {
return Scaffold(
backgroundColor: Colors.black,
appBar: CustomAppBar(
child: Column(
crossAxisAlignment: CrossAxisAlignment.start,
children: [
SizedBox(
height: 40,
),
Padding(
padding: const EdgeInsets.only(left: 24.0, right: 20),
child: Row(
mainAxisAlignment: MainAxisAlignment.spaceBetween,
children: [
Icon(
Icons.arrow_back,
size: 24,
color: Colors.white,
),
Icon(
Icons.settings,
size: 24,
color: Colors.white,
)
],
),
),
SizedBox(
height: 20,
),
Padding(
padding: const EdgeInsets.only(left: 24.0, right: 20),
child: Text(
"Resultados da busca",
maxLines: 1,
overflow: TextOverflow.ellipsis,
style: TextStyle(
color: Colors.white,
fontWeight: FontWeight.bold,
fontSize: 32),
),
)
],
),
height: 140,
),
body: Column(
children: [
SearchBox(
enable: true,
controller: controller,
hint: "Procure planetas, asteroides, estrelas...",
),
Flexible(
child: ListView.builder(
padding: EdgeInsets.all(24),
itemBuilder: (BuildContext context, int index) {
return GestureDetector(
onTap: () {
Navigator.push(
context,
MaterialPageRoute(
builder: (context) => DetailPage(
planet: planets[index],
),
));
},
child: Padding(
padding: const EdgeInsets.only(bottom: 16.0),
child: ClipRRect(
borderRadius: BorderRadius.circular(8),
child: Container(
height: MediaQuery.of(context).size.height * 0.25,
decoration: BoxDecoration(
color: god_gray,
borderRadius: BorderRadius.all(Radius.circular(8))),
child: Stack(
children: [
Positioned(
left: -50,
top: -30,
child: Hero(
tag: planets[index].id,
child: SvgPicture.asset(
planets[index].iconPath,
width:
MediaQuery.of(context).size.width * 0.2,
height:
MediaQuery.of(context).size.height * 0.25,
)),
),
Padding(
padding: const EdgeInsets.all(16.0),
child: Row(
children: [
Expanded(
flex: 1,
child: SizedBox(),
),
Expanded(
flex: 1,
child: Column(
children: [
Row(
mainAxisAlignment:
MainAxisAlignment.spaceBetween,
children: [
CustomText(
text: planets[index].title,
maxLines: 1,
size: 32,
color: Colors.white,
),
Icon(Icons.bookmark_border,
color: white_65)
],
),
Padding(padding: EdgeInsets.all(8)),
CustomText(
size: 14,
color: white_65,
maxLines: 4,
text:
"Netuno é o oitavo planeta do Sistema Solar, o último a partir do Sol desde a reclassificação...",
),
Padding(padding: EdgeInsets.all(8)),
Row(
children: [
CustomText(
size: 14,
color: Colors.white,
maxLines: 1,
text: "Continue lendo",
),
SizedBox(
width: 10,
),
Icon(
Icons.arrow_forward,
color: salmon,
)
],
)
],
),
)
],
),
),
],
),
),
),
),
);
},
itemCount: planets.length,
))
],
),
);
}
}
| 0 |
mirrored_repositories/flutter_ui_concept_solor_system/lib | mirrored_repositories/flutter_ui_concept_solor_system/lib/screens/home.dart | import 'package:flutter/material.dart';
import 'package:flutter_svg/svg.dart';
import 'package:flutter_ui_concept_solar_system/colors.dart';
import 'package:flutter_ui_concept_solar_system/screens/bookmark.dart';
import 'package:flutter_ui_concept_solar_system/screens/gallery.dart';
import 'package:flutter_ui_concept_solar_system/screens/home_screen.dart';
import 'package:flutter_ui_concept_solar_system/screens/search.dart';
class HomePage extends StatefulWidget {
const HomePage({Key key}) : super(key: key);
@override
_HomePageState createState() => _HomePageState();
}
class _HomePageState extends State<HomePage> {
List<Widget> widgets = [];
int _selectedIndex = 0;
void _onItemTapped(int index) {
setState(() {
_selectedIndex = index;
});
}
@override
void initState() {
widgets.add(HomeScreen());
widgets.add(SearchScreen());
widgets.add(BookmarkScreen());
widgets.add(GalleryPage());
super.initState();
}
@override
Widget build(BuildContext context) {
return Scaffold(
backgroundColor: Colors.black,
body: widgets.elementAt(_selectedIndex),
bottomNavigationBar: ClipRRect(
borderRadius: BorderRadius.only(
topLeft: Radius.circular(16),
topRight: Radius.circular(16),
),
child: Theme(
data: Theme.of(context).copyWith(canvasColor: Colors.black),
child: BottomNavigationBar(
backgroundColor: god_gray,
items: const <BottomNavigationBarItem>[
BottomNavigationBarItem(
title: Text("Home"),
icon: Icon(Icons.home),
),
BottomNavigationBarItem(
title: Text("Search"),
icon: Icon(Icons.search),
),
BottomNavigationBarItem(
title: Text("Save"),
icon: Icon(Icons.bookmark),
),
BottomNavigationBarItem(
title: Text("Gallery"),
icon: Icon(Icons.image),
),
],
unselectedItemColor: white_65,
currentIndex: _selectedIndex,
selectedItemColor: Colors.white,
onTap: _onItemTapped,
),
),
),
);
}
}
| 0 |
mirrored_repositories/flutter_ui_concept_solor_system | mirrored_repositories/flutter_ui_concept_solor_system/test/widget_test.dart | // This is a basic Flutter widget test.
//
// To perform an interaction with a widget in your test, use the WidgetTester
// utility that Flutter provides. For example, you can send tap and scroll
// gestures. You can also use WidgetTester to find child widgets in the widget
// tree, read text, and verify that the values of widget properties are correct.
import 'package:flutter/material.dart';
import 'package:flutter_test/flutter_test.dart';
import 'package:flutter_ui_concept_solar_system/main.dart';
void main() {
testWidgets('Counter increments smoke test', (WidgetTester tester) async {
// Build our app and trigger a frame.
await tester.pumpWidget(MyApp());
// Verify that our counter starts at 0.
expect(find.text('0'), findsOneWidget);
expect(find.text('1'), findsNothing);
// Tap the '+' icon and trigger a frame.
await tester.tap(find.byIcon(Icons.add));
await tester.pump();
// Verify that our counter has incremented.
expect(find.text('0'), findsNothing);
expect(find.text('1'), findsOneWidget);
});
}
| 0 |
mirrored_repositories/kryptonian-flutter-app | mirrored_repositories/kryptonian-flutter-app/lib/main.dart | /// @@@ Kryptonian Shop APP @@@
/// @@@ version: 5.4-stable @@@
/// @@@ Environment: Staging
/// @@@ App Features: KB-30-Publish-krypton-PlayStore-stable ✨
/// @@@ WebServer: FireBase @@@
/// @@@ AUTHOR: Maushook @@@
/// @@@ COPYRIGHT: Neural Bots Inc @@@
import 'package:animated_theme_switcher/animated_theme_switcher.dart';
import 'package:firebase_core/firebase_core.dart';
import 'package:flutter/material.dart';
import 'package:flutter/scheduler.dart';
import 'package:flutter/widgets.dart';
import 'package:flutter_complete_guide/providers/auth.dart';
import 'package:flutter_complete_guide/providers/cart.dart';
import 'package:flutter_complete_guide/providers/categories.dart';
import 'package:flutter_complete_guide/providers/light.dart';
import 'package:flutter_complete_guide/providers/orders.dart';
import 'package:flutter_complete_guide/providers/products.dart';
import 'package:flutter_complete_guide/providers/users.dart';
import 'package:flutter_complete_guide/screens/auth_screen.dart';
import 'package:flutter_complete_guide/screens/cart_screen.dart';
import 'package:flutter_complete_guide/screens/categories_screen.dart';
import 'package:flutter_complete_guide/screens/edit_product_screen.dart';
import 'package:flutter_complete_guide/screens/liquid_welcome_screen.dart';
import 'package:flutter_complete_guide/screens/orders_screen.dart';
import 'package:flutter_complete_guide/screens/product_details_screen.dart';
import 'package:flutter_complete_guide/screens/products_overview_screen.dart';
import 'package:flutter_complete_guide/screens/my_splash_screen.dart';
import 'package:flutter_complete_guide/screens/user_products_screen.dart';
import 'package:provider/provider.dart';
import 'package:flutter_dotenv/flutter_dotenv.dart';
import 'helpers/theme_config.dart';
Future main() async {
WidgetsFlutterBinding.ensureInitialized();
await Firebase.initializeApp();
await dotenv.load(fileName: "assets/.env");
runApp(MyApp());
}
class MyApp extends StatelessWidget {
@override
Widget build(BuildContext context) {
var brightness = SchedulerBinding.instance.window.platformBrightness;
final initTheme = brightness == Brightness.dark ? nightTheme : dayTheme;
return MultiProvider(
providers: [
/// ChangeNotifierProvider Builder with Initialised Objects Products
/// Anywhere below the child of the Providers, you can listen to the
/// provided values using Provider.of<Products>(content)
/// OR Using Consumer<Products>()
ChangeNotifierProvider(create: (ctx) => Auth()),
ChangeNotifierProxyProvider<Auth, Users>(
create: (ctx) => Users('', '', []),
update: (ctx, auth, previousUsers) => Users(
auth.token,
auth.userId,
previousUsers == null ? [] : previousUsers.usersList,
),
),
ChangeNotifierProxyProvider<Auth, Products>(
create: (ctx) => Products('', '', []),
update: (ctx, auth, previousProducts) => Products(
auth.token,
auth.userId,
previousProducts == null ? [] : previousProducts.item,
),
),
ChangeNotifierProxyProvider<Auth, Categories>(
create: (ctx) => Categories('', []),
update: (ctx, auth, previousCategories) => Categories(
auth.token,
previousCategories == null ? [] : previousCategories.categories,
),
),
ChangeNotifierProvider(create: (ctx) => Cart()),
ChangeNotifierProvider(create: (ctx) => Light()),
ChangeNotifierProxyProvider<Auth, Orders>(
create: (ctx) => Orders('', '', []),
update: (ctx, auth, previousOrders) => Orders(
auth.token,
auth.userId,
previousOrders == null ? [] : previousOrders.orders,
),
),
],
child: Consumer<Auth>(
builder: (ctx, authData, _) {
print('BUILD => MAIN');
return ThemeProvider(
initTheme: dayTheme,
builder: (_, myTheme) => MaterialApp(
title: 'Krypton',
theme: myTheme,
//home: authData.isAuth == true ? ProductsOverviewScreen() : Welcome(),
routes: {
'/': (ctx) => authData.isAuth
? CategoriesScreen()
: FutureBuilder(
future: authData.tryAutoLogin(),
builder: (context, snapshot) =>
snapshot.connectionState == ConnectionState.waiting
? MySplashScreen()
: LiquidWelcomeScreen(),
),
//LiquidAppSwitchScreen.routeName: (ctx) => LiquidAppSwitchScreen(),
CategoriesScreen.routeName: (ctx) => CategoriesScreen(),
AuthScreen.routeName: (ctx) => AuthScreen(),
ProductsOverviewScreen.routeName: (ctx) =>
ProductsOverviewScreen(),
ProductDetailsScreen.routeName: (ctx) => ProductDetailsScreen(),
CartScreen.routeName: (ctx) => CartScreen(),
OrdersScreen.routeName: (ctx) => OrdersScreen(),
UserProductsScreen.routeName: (ctx) => UserProductsScreen(),
EditProductScreen.routeName: (ctx) => EditProductScreen(),
},
debugShowCheckedModeBanner: false,
),
);
},
),
);
}
}
| 0 |
mirrored_repositories/kryptonian-flutter-app/lib | mirrored_repositories/kryptonian-flutter-app/lib/pallete/purplay.dart | ///purplay.dart
///Custom Colors => Primary Swatch
import 'package:flutter/material.dart';
class Purplay {
static const MaterialColor kToDark = const MaterialColor(
0xff4c1a54, // 0% comes in here, this will be color picked if no shade is selected when defining a Color property which doesn’t require a swatch.
const <int, Color>{
50: const Color(0xff947698), //10%
100: const Color(0xff947698), //20%
200: const Color(0xff704876), //30%
300: const Color(0xff684876), //40%
400: const Color(0xff6f4876), //50%
500: const Color(0xff4f1a54), //60%
600: const Color(0xff4f1a54), //70%
700: const Color(0xff5f3165), //80%
800: const Color(0xff5f1a54), //90%
900: const Color(0xff4c1a54), //100%
},
);
}
| 0 |
mirrored_repositories/kryptonian-flutter-app/lib | mirrored_repositories/kryptonian-flutter-app/lib/pallete/deepBlue.dart | ///deepBlue.dart
///Custom Colors => Primary Swatch
import 'package:flutter/material.dart';
class DeepBlue {
static const MaterialColor kToDark = const MaterialColor(
0xff152238, // 0% comes in here, this will be color picked if no shade is selected when defining a Color property which doesn’t require a swatch.
const <int, Color>{
50: const Color(0xff23395d), //10%
100: const Color(0xff23395d), //20%
200: const Color(0xff203354), //30%
300: const Color(0xff1c2e4a), //40%
400: const Color(0xff192841), //50%
500: const Color(0xff152238), //60%
600: const Color(0xff152238), //70%
700: const Color(0xff012023), //80%
800: const Color(0xff001012), //90%
900: const Color(0xff000000), //100%
},
);
}
| 0 |
mirrored_repositories/kryptonian-flutter-app/lib | mirrored_repositories/kryptonian-flutter-app/lib/pallete/turquoise.dart | ///turquoise.dart
///Custom Colors => Primary Swatch
import 'package:flutter/material.dart';
class Turquoise {
static const MaterialColor kToDark = const MaterialColor(
0xff035f6a, // 0% comes in here, this will be color picked if no shade is selected when defining a Color property which doesn’t require a swatch.
const <int, Color>{
50: const Color(0xff058f9e), //10%
100: const Color(0xff047f8d), //20%
200: const Color(0xff046f7b), //30%
300: const Color(0xff035f6a), //40%
400: const Color(0xff035058), //50%
500: const Color(0xff024046), //60%
600: const Color(0xff013035), //70%
700: const Color(0xff012023), //80%
800: const Color(0xff001012), //90%
900: const Color(0xff000000), //100%
},
);
}
| 0 |
mirrored_repositories/kryptonian-flutter-app/lib | mirrored_repositories/kryptonian-flutter-app/lib/widgets/circular_menu.dart | import 'dart:async';
import 'package:animated_theme_switcher/animated_theme_switcher.dart';
import 'package:flutter/material.dart';
import 'package:fab_circular_menu/fab_circular_menu.dart';
import 'package:flutter_complete_guide/helpers/theme_config.dart';
import 'package:flutter_complete_guide/pallete/deepBlue.dart';
import 'package:flutter_complete_guide/providers/auth.dart';
import 'package:flutter_complete_guide/providers/light.dart';
import 'package:flutter_complete_guide/providers/users.dart';
import 'package:flutter_complete_guide/screens/cart_screen.dart';
import 'package:flutter_complete_guide/screens/categories_screen.dart';
import 'package:flutter_complete_guide/screens/liquid_app_switch_screen.dart';
import 'package:flutter_complete_guide/screens/orders_screen.dart';
import 'package:flutter_complete_guide/screens/products_overview_screen.dart';
import 'package:flutter_complete_guide/screens/user_products_screen.dart';
import 'package:provider/provider.dart';
class CircularMenu extends StatelessWidget {
final GlobalKey<FabCircularMenuState> fabKey = GlobalKey();
void _tapHandler(BuildContext context, String routeName, arguments) {
Navigator.of(context).pushNamed(routeName, arguments: arguments);
}
@override
Widget build(BuildContext context) {
final lightData = Provider.of<Light>(context, listen: false);
final isDark = lightData.themeDark;
return Builder(
builder: (context) => Consumer<Users>(
builder: (ctx, userData, _) => FabCircularMenu(
key: fabKey,
alignment: Alignment.bottomRight,
ringColor: Colors.black.withAlpha(180),
ringDiameter: 500.0,
ringWidth: 160.0,
fabSize: 64.0,
fabElevation: 32.0,
fabIconBorder: CircleBorder(),
fabColor: isDark ? Colors.deepOrangeAccent : DeepBlue.kToDark,
fabOpenIcon: Icon(
Icons.menu,
color: isDark ? DeepBlue.kToDark : Colors.deepOrangeAccent,
size: 30,
),
fabCloseIcon: Icon(
Icons.close,
color: isDark ? DeepBlue.kToDark : Colors.deepOrangeAccent,
size: 30,
),
fabMargin: const EdgeInsets.all(16.0),
animationDuration: const Duration(milliseconds: 800),
animationCurve: Curves.easeInOutCirc,
onDisplayChange: (isOpen) {
//_showSnackBar(context, "The menu is ${isOpen ? "open" : "closed"}");
},
children: <Widget>[
ThemeSwitcher(
clipper: ThemeSwitcherBoxClipper(),
builder: (ctx) => IconButton(
icon: Icon(isDark ? Icons.wb_sunny : Icons.nights_stay_sharp),
color: isDark ? Colors.yellow : Colors.white,
onPressed: () {
lightData.toggleLights();
Timer(
Duration(milliseconds: 50),
() => ThemeSwitcher.of(ctx)
.changeTheme(theme: isDark ? dayTheme : nightTheme),
);
},
),
),
IconButton(
onPressed: () {
_tapHandler(ctx, ProductsOverviewScreen.routeName, ['', false]);
fabKey.currentState.close();
},
icon: Icon(Icons.shop,
color: isDark ? Colors.deepOrange : Colors.lightBlueAccent,
size: 30),
),
IconButton(
onPressed: () {
_tapHandler(ctx, CategoriesScreen.routeName, null);
fabKey.currentState.close();
},
icon: Icon(Icons.category,
color: isDark ? Colors.deepOrange : Colors.lightBlueAccent,
size: 30),
),
IconButton(
onPressed: () {
_tapHandler(ctx, OrdersScreen.routeName, null);
fabKey.currentState.close();
},
icon: Icon(Icons.credit_card,
color: isDark ? Colors.deepOrange : Colors.lightBlueAccent,
size: 30),
),
IconButton(
onPressed: () {
_tapHandler(ctx, CartScreen.routeName, null);
fabKey.currentState.close();
},
icon: Icon(
Icons.add_shopping_cart_sharp,
color: isDark ? Colors.deepOrange : Colors.lightBlueAccent,
size: 30,
),
),
if (userData.fetchIsSeller == true &&
userData.fetchIsSeller != null)
IconButton(
onPressed: () {
_tapHandler(ctx, UserProductsScreen.routeName, null);
fabKey.currentState.close();
},
icon: Icon(Icons.manage_accounts,
color: isDark ? Colors.teal : Colors.red, size: 30),
),
IconButton(
onPressed: () {
Navigator.of(ctx).pop();
Navigator.of(ctx).pushNamed('/');
Provider.of<Auth>(ctx, listen: false).logout();
fabKey.currentState.close();
},
icon: Icon(Icons.exit_to_app,
color: isDark ? Colors.deepOrange : Colors.lightBlueAccent,
size: 30),
),
],
),
),
);
}
void _showSnackBar(BuildContext context, String message) {
Scaffold.of(context).showSnackBar(SnackBar(
backgroundColor: Colors.black54,
content: Text(message),
duration: const Duration(milliseconds: 1000),
));
}
}
| 0 |
mirrored_repositories/kryptonian-flutter-app/lib | mirrored_repositories/kryptonian-flutter-app/lib/widgets/products_grid.dart | import 'package:flutter/material.dart';
import 'package:flutter_complete_guide/providers/products.dart';
import 'package:flutter_complete_guide/widgets/product_item.dart';
import 'package:provider/provider.dart';
class productsGrid extends StatelessWidget {
final bool showFavoriteOnly;
final String categoryId;
final bool categoryFlag;
productsGrid({this.showFavoriteOnly, this.categoryId, this.categoryFlag});
@override
Widget build(BuildContext context) {
//final productData = Provider.of<Products>(context);
//final products = productData.item;
//final filteredProducts = showFavoriteOnly ? productData.favoriteItems : products;
/// Fetch Products by Categories:-
final filteredProducts = Provider.of<Products>(context)
.fetchProductByCategories(categoryId, categoryFlag);
return GridView.builder(
itemCount: filteredProducts.length,
itemBuilder: (ctx, index) => ChangeNotifierProvider.value(
value: filteredProducts[index],
child: ProductItem(index: index),
),
gridDelegate: SliverGridDelegateWithFixedCrossAxisCount(
childAspectRatio: 3 / 2,
mainAxisSpacing: 10,
crossAxisSpacing: 10,
crossAxisCount: 2,
),
);
}
}
| 0 |
mirrored_repositories/kryptonian-flutter-app/lib | mirrored_repositories/kryptonian-flutter-app/lib/widgets/cart_item.dart | import 'package:flutter/material.dart';
import 'package:flutter_complete_guide/providers/cart.dart';
import 'package:flutter_complete_guide/providers/light.dart';
import 'package:flutter_complete_guide/providers/products.dart';
import 'package:provider/provider.dart';
class CartItem extends StatelessWidget {
final String id;
final String productId;
final String title;
final int quantity;
final double price;
CartItem({
@required this.id,
@required this.productId,
@required this.title,
@required this.quantity,
@required this.price,
});
@override
Widget build(BuildContext context) {
final cartData = Provider.of<Cart>(context);
final productsData = Provider.of<Products>(context);
return Dismissible(
key: ValueKey(id),
direction: DismissDirection.endToStart,
confirmDismiss: (direction) {
return showDialog(
context: context,
builder: (ctx) => AlertDialog(
elevation: 10.4,
contentPadding: EdgeInsets.all(30.0),
title: Text('Attention', textAlign: TextAlign.center),
content: Text(
'Do you want to remove this item?',
textAlign: TextAlign.center,
),
actions: [
TextButton(
onPressed: () => Navigator.of(ctx).pop(false),
child: Text('No'),
),
TextButton(
onPressed: () {
cartData.deleteItems(productId);
productsData.clearUnitProductQuantity(productId);
Navigator.of(ctx).pop(true);
},
child: Text('Yes'),
),
],
),
);
},
onDismissed: (direction) {
cartData.deleteItems(productId);
productsData.clearUnitProductQuantity(productId);
},
background: Container(
color: Theme.of(context).errorColor,
child: Icon(
Icons.delete,
color: Colors.white,
size: 40,
),
alignment: Alignment.centerRight,
padding: EdgeInsets.only(right: 20),
margin: EdgeInsets.symmetric(vertical: 4, horizontal: 15),
),
child: Card(
margin: EdgeInsets.symmetric(vertical: 4, horizontal: 15),
child: Padding(
padding: EdgeInsets.all(8),
child: ListTile(
leading: CircleAvatar(
backgroundColor: Provider.of<Light>(context).themeDark
? Colors.black
: AppBarTheme.of(context).backgroundColor,
radius: 28,
child: Padding(
padding: const EdgeInsets.all(5.0),
child: FittedBox(
child:
Text('\$${price}', style: TextStyle(color: Colors.white)),
),
),
),
title: Text(title),
subtitle: Text('Total: \$${(price * quantity).toStringAsFixed(2)}'),
trailing: Text('${quantity} x'),
),
),
),
);
}
}
| 0 |
mirrored_repositories/kryptonian-flutter-app/lib | mirrored_repositories/kryptonian-flutter-app/lib/widgets/social_sign_in_button.dart | import 'package:flutter/material.dart';
import 'package:flutter_complete_guide/widgets/custom_raised_button.dart';
class SocialSignInButton extends CustomRaisedButton {
SocialSignInButton({
@required String assetName,
@required String text,
Color backgroundColor,
Color textColor,
VoidCallback onPressed,
}) : assert(assetName != null),
assert(text != null),
super(
child: Row(
mainAxisAlignment: MainAxisAlignment.spaceEvenly,
children: [
Image.asset(assetName),
Text(text),
Opacity(
opacity: 0.0,
child: Image.asset(assetName),
),
],
),
backgroundColor: backgroundColor,
textColor: textColor,
fontSize: 15.0,
borderRadius: 4.0,
height: 40.0,
onPressed: onPressed,
);
} | 0 |
mirrored_repositories/kryptonian-flutter-app/lib | mirrored_repositories/kryptonian-flutter-app/lib/widgets/main_drawer.dart | import 'package:flutter/material.dart';
import 'package:flutter_complete_guide/pallete/deepBlue.dart';
import 'package:flutter_complete_guide/providers/auth.dart';
import 'package:flutter_complete_guide/providers/products.dart';
import 'package:flutter_complete_guide/providers/users.dart';
import 'package:flutter_complete_guide/screens/cart_screen.dart';
import 'package:flutter_complete_guide/screens/categories_screen.dart';
import 'package:flutter_complete_guide/screens/liquid_app_switch_screen.dart';
import 'package:flutter_complete_guide/screens/orders_screen.dart';
import 'package:flutter_complete_guide/screens/products_overview_screen.dart';
import 'package:flutter_complete_guide/screens/user_products_screen.dart';
import 'package:provider/provider.dart';
class MainDrawer extends StatelessWidget {
void _tapHandler(BuildContext context, String routeName, arguments) {
Navigator.of(context).popAndPushNamed(routeName, arguments: arguments);
}
@override
Widget build(BuildContext context) {
final username = Provider.of<Users>(context, listen: false).userName;
return Consumer<Users>(
builder: (context, userData, _) => Drawer(
child: Column(
children: <Widget>[
Container(
height: 120,
width: double.infinity,
padding: EdgeInsets.all(20),
alignment: Alignment.centerLeft,
color: Theme.of(context).appBarTheme.backgroundColor,
child: Text(
'Hello ${username ?? ''}!',
style: TextStyle(
fontSize: 30,
color: Colors.white,
fontWeight: FontWeight.bold),
),
),
SizedBox(height: 20),
ListTile(
leading: Icon(
Icons.shop,
size: 30,
color: DeepBlue.kToDark.shade50,
),
title: Text(
'Shop',
style: TextStyle(fontSize: 18, fontFamily: 'Anton-Regular'),
),
onTap: () => _tapHandler(
context, ProductsOverviewScreen.routeName, ['', false]),
),
Divider(),
ListTile(
leading: Icon(
Icons.category,
size: 30,
color: DeepBlue.kToDark.shade50,
),
title: Text(
'All Categories',
style: TextStyle(fontSize: 18, fontFamily: 'Anton-Regular'),
),
onTap: () =>
_tapHandler(context, CategoriesScreen.routeName, null),
),
Divider(),
ListTile(
leading: Icon(
Icons.credit_card,
size: 30,
color: DeepBlue.kToDark.shade50,
),
title: Text(
'My Orders',
style: TextStyle(fontSize: 18, fontFamily: 'Anton-Regular'),
),
onTap: () => _tapHandler(context, OrdersScreen.routeName, null),
),
Divider(),
_buildListTile(context, 'My Cart', Icons.add_shopping_cart_sharp,
CartScreen.routeName, null, DeepBlue.kToDark.shade50),
Divider(),
if (userData.fetchIsSeller == true &&
userData.fetchIsSeller != null)
_buildListTile(context, 'Manage Products', Icons.manage_accounts,
UserProductsScreen.routeName, null, Colors.red),
if (userData.fetchIsSeller == true &&
userData.fetchIsSeller != null)
Divider(),
ListTile(
leading: Icon(
Icons.exit_to_app,
size: 30,
color: DeepBlue.kToDark.shade50,
),
title: Text(
'Logout',
style: TextStyle(fontSize: 18, fontFamily: 'Anton-Regular'),
),
onTap: () {
Navigator.of(context).pop();
Navigator.of(context).pushReplacementNamed('/');
Provider.of<Auth>(context, listen: false).logout();
},
),
],
),
),
);
}
ListTile _buildListTile(BuildContext context, String title, IconData icon,
route, arguments, Color color) {
return ListTile(
leading: Icon(
icon,
size: 30,
color: color,
),
title: Text(
title,
style: TextStyle(fontSize: 18, fontFamily: 'Anton-Regular'),
),
onTap: () => _tapHandler(context, route, arguments),
);
}
}
| 0 |
mirrored_repositories/kryptonian-flutter-app/lib | mirrored_repositories/kryptonian-flutter-app/lib/widgets/welcome.dart | import 'dart:math';
import 'package:flutter/cupertino.dart';
import 'package:flutter/material.dart';
import 'package:flutter_complete_guide/helpers/custom_route.dart';
import 'package:flutter_complete_guide/screens/auth_screen.dart';
//import 'package:google_fonts/google_fonts.dart';
class Welcome extends StatefulWidget {
@override
State<Welcome> createState() => _WelcomeState();
}
class _WelcomeState extends State<Welcome> with TickerProviderStateMixin {
AnimationController _controllerBh;
AnimationController _controllerAst;
@override
void initState() {
// TODO: implement initState
_controllerBh =
AnimationController(vsync: this, duration: Duration(minutes: 3))
..repeat();
_controllerAst =
AnimationController(vsync: this, duration: Duration(minutes: 15))
..repeat();
super.initState();
}
@override
void dispose() {
// TODO: implement dispose
_controllerBh.dispose();
_controllerAst.dispose();
super.dispose();
}
@override
Widget build(BuildContext context) {
final deviceSize = MediaQuery.of(context).size;
return Material(
type: MaterialType.transparency,
child: Stack(
children: [
Positioned.fill(
child: Image.asset(
'assets/images/Welcome.png',
fit: BoxFit.cover,
),
),
Container(
decoration: BoxDecoration(
gradient: LinearGradient(
colors: [
Color(0xff18203d).withOpacity(1),
Color(0xff18203d).withOpacity(1),
Colors.black.withOpacity(1),
Color(0xff232c51),
],
begin: Alignment.topLeft,
end: Alignment.bottomRight,
stops: [0, 0, 1, 1],
),
),
),
Positioned(
child: Align(
child: Container(
padding: EdgeInsets.only(
top: deviceSize.height * 0.2,
bottom: deviceSize.height * 0.0,
right: deviceSize.height * 0.0,
left: deviceSize.height * 0.0,
),
child: _buildBottomAnimatedAsteroid(context, deviceSize),
),
),
),
Container(
padding: EdgeInsets.only(
top: deviceSize.height * 0,
bottom: deviceSize.height * 0.15,
right: deviceSize.height * 0,
left: deviceSize.height * 0,
),
child: _buildAnimatedBlackHole(context, deviceSize),
),
Container(
padding: EdgeInsets.only(
top: deviceSize.height * 0,
bottom: deviceSize.height * 0.15,
right: deviceSize.height * 0,
left: deviceSize.height * 0,
),
child: _buildTopAnimatedAsteroid(context, deviceSize),
),
const Center(),
Container(
margin: const EdgeInsets.only(left: 25),
child: Column(
mainAxisAlignment: MainAxisAlignment.center,
crossAxisAlignment: CrossAxisAlignment.start,
children: [
Container(
margin: EdgeInsets.only(
top: deviceSize.height * 0.61,
),
child: Text(
'Kryptonian Boutique',
style: TextStyle(
fontFamily: 'Poppins',
fontWeight: FontWeight.w500,
fontSize: 30,
color: Colors.white,
),
),
),
Container(
margin: const EdgeInsets.only(top: 10),
width: 350,
child: Text(
"A Futuristic Shopping Platform with Unique User Experience. Almost like transcending to Space!",
style: TextStyle(
fontFamily: 'Poppins',
fontSize: 17,
color: const Color(0xffBABABA),
fontWeight: FontWeight.normal),
),
),
Container(
margin: const EdgeInsets.only(
top: 20,
),
// color: Colors.green,
child: ElevatedButton(
onPressed: () => Navigator.of(context).pushReplacement(
CustomRoute(builder: (ctx) => AuthScreen())),
//Navigator.of(context).pushNamed(AuthScreen.routeName),
style: ElevatedButton.styleFrom(
fixedSize: const Size(199, 50),
//primary: const Color(0xffC65466),
primary: Colors.lightBlue.shade600,
shape: RoundedRectangleBorder(
borderRadius: BorderRadius.circular(18))),
child: Row(
// mainAxisAlignment: MainAxisAlignment.spaceBetween,
children: [
Text(
'Get started',
style: TextStyle(
fontFamily: 'Poppins',
fontSize: 17,
color: Colors.white,
),
),
Container(
margin: const EdgeInsets.only(left: 40),
child: const Icon(
Icons.arrow_forward_ios,
color: Colors.white,
),
)
],
),
),
)
],
),
),
],
),
);
}
Widget _buildAnimatedBlackHole(BuildContext context, Size deviceSize) {
return AnimatedBuilder(
animation: _controllerBh,
builder: (_, ch) {
return Transform.rotate(
angle: _controllerBh.value * 2 * pi,
child: ch,
);
},
child: Image.asset(
'assets/images/Black-Hole.png',
width: 460,
height: 420,
fit: BoxFit.fill,
),
);
}
Widget _buildTopAnimatedAsteroid(BuildContext context, Size deviceSize) {
return AnimatedBuilder(
animation: _controllerAst,
builder: (_, ch) {
return Transform.rotate(
angle: -_controllerAst.value * 2 * pi,
child: ch,
);
},
child: Image.asset(
'assets/images/asteroid-belt-1.png',
width: 500,
height: 180,
fit: BoxFit.cover,
),
);
}
Widget _buildBottomAnimatedAsteroid(BuildContext context, Size deviceSize) {
return AnimatedBuilder(
animation: _controllerAst,
builder: (_, ch) {
return Transform.rotate(
angle: _controllerAst.value * 10 * pi,
child: ch,
);
},
child: Image.asset(
'assets/images/asteroid-belt.png',
width: 500,
height: 180,
fit: BoxFit.cover,
),
);
}
}
| 0 |
mirrored_repositories/kryptonian-flutter-app/lib | mirrored_repositories/kryptonian-flutter-app/lib/widgets/sign_in_button.dart | import 'package:flutter/material.dart';
import 'package:flutter_complete_guide/widgets/custom_raised_button.dart';
class SignInButton extends CustomRaisedButton {
SignInButton({
@required String text,
Color backgroundColor,
Color textColor,
VoidCallback onPressed,
}) : assert(text != null),
super(
child: Text(text),
backgroundColor: backgroundColor,
textColor: textColor,
fontSize: 15.0,
borderRadius: 4.0,
height: 40.0,
onPressed: onPressed,
);
}
| 0 |
mirrored_repositories/kryptonian-flutter-app/lib | mirrored_repositories/kryptonian-flutter-app/lib/widgets/user_product_item.dart | import 'package:flutter/cupertino.dart';
import 'package:flutter/gestures.dart';
import 'package:flutter/material.dart';
import 'package:flutter_complete_guide/pallete/deepBlue.dart';
import 'package:flutter_complete_guide/providers/auth.dart';
import 'package:flutter_complete_guide/providers/cart.dart';
import 'package:flutter_complete_guide/providers/products.dart';
import 'package:flutter_complete_guide/screens/edit_product_screen.dart';
import 'package:flutter_complete_guide/screens/products_overview_screen.dart';
import 'package:flutter_slidable/flutter_slidable.dart';
import 'package:provider/provider.dart';
class UserProductItem extends StatefulWidget {
final int index;
final String productId;
final String title;
final String imageUrl;
UserProductItem({
@required this.index,
@required this.productId,
@required this.title,
@required this.imageUrl,
});
@override
State<UserProductItem> createState() => _UserProductItemState();
}
class _UserProductItemState extends State<UserProductItem> {
bool _isImgErr = false;
@override
void initState() {
// TODO: implement initState
super.initState();
}
@override
void didChangeDependencies() {
// TODO: implement didChangeDependencies
setState(() {
_isImgErr = false;
});
super.didChangeDependencies();
}
void _productDismissHandler(DismissDirection direction, BuildContext context,
Products productsData, Cart cartData) async {
String auth = Provider.of<Auth>(context, listen: false).token;
if (direction == DismissDirection.endToStart) {
/// Right -> Left => DELETE
cartData.deleteItems(widget.productId);
try {
await productsData.deleteProduct(widget.productId);
ScaffoldMessenger.of(context).showSnackBar(
SnackBar(
content: Text('Product Deleted!'),
),
);
} catch (error) {
await showDialog<Null>(
context: context,
builder: (context) => AlertDialog(
elevation: 10.4,
title: Text('Attention Schmuck', textAlign: TextAlign.center),
content: Text('Something Went Wrong. Try Deleting Product later!',
textAlign: TextAlign.center),
actions: [
TextButton(
onPressed: () => Navigator.of(context).pop(),
child: Text('Close'),
),
],
),
);
}
} else if (direction == DismissDirection.startToEnd) {
/// Left -> Right => EDIT
Navigator.of(context)
.pushNamed(EditProductScreen.routeName, arguments: widget.productId);
}
}
void _callEditProductHandler() {
Navigator.of(context)
.pushNamed(EditProductScreen.routeName, arguments: widget.productId);
}
void _callDeleteProductHandler(Products productsData, Cart cartData) async {
cartData.deleteItems(widget.productId);
try {
await productsData.deleteProduct(widget.productId);
ScaffoldMessenger.of(context).showSnackBar(
SnackBar(
backgroundColor: DeepBlue.kToDark,
content: Text(
'Product Deleted!',
style: TextStyle(color: Colors.white, fontWeight: FontWeight.bold),
),
),
);
} catch (error) {
await showDialog<Null>(
context: context,
builder: (context) => AlertDialog(
elevation: 10.4,
title: Text('Attention Schmuck', textAlign: TextAlign.center),
content: Text('Something Went Wrong. Try Deleting Product later!',
textAlign: TextAlign.center),
actions: [
TextButton(
onPressed: () => Navigator.of(context).pop(),
child: Text('Close'),
),
],
),
);
}
}
@override
Widget build(BuildContext context) {
final productsData = Provider.of<Products>(context, listen: true);
final cartData = Provider.of<Cart>(context);
return Slidable(
key: const ValueKey(0),
endActionPane: ActionPane(
motion: ScrollMotion(),
children: [
SlidableAction(
key: const ValueKey(0),
flex: 2,
onPressed: (ctx) => _callEditProductHandler(),
backgroundColor: Colors.teal,
foregroundColor: Colors.white,
icon: Icons.edit,
label: 'Edit',
),
SlidableAction(
key: const ValueKey(1),
flex: 2,
onPressed: (ctx) => showDialog(
context: ctx,
builder: (context) => AlertDialog(
elevation: 10.4,
contentPadding: EdgeInsets.all(30.0),
title: Text('Attention', textAlign: TextAlign.center),
content: Text(
'Do you want to remove this item?',
textAlign: TextAlign.center,
),
actions: [
TextButton(
onPressed: () => Navigator.of(context).pop(false),
child: Text('No'),
),
TextButton(
onPressed: () {
_callDeleteProductHandler(productsData, cartData);
Navigator.of(context).pop(true);
},
child: Text('Yes'),
),
],
),
),
backgroundColor: Colors.red,
foregroundColor: Colors.white,
icon: Icons.delete,
label: 'Delete',
),
],
),
child: Card(
margin: EdgeInsets.symmetric(vertical: 4, horizontal: 15),
child: ListTile(
title: Text(widget.title),
leading: _isImgErr == false
? CircleAvatar(
backgroundImage: NetworkImage(widget.imageUrl),
onBackgroundImageError: (error, _) {
setState(() {
_isImgErr = true;
});
},
)
: CircleAvatar(
backgroundImage:
AssetImage('assets/images/placeholder.png'),
),
trailing: Icon(Icons.double_arrow_sharp)),
),
);
}
}
| 0 |
mirrored_repositories/kryptonian-flutter-app/lib | mirrored_repositories/kryptonian-flutter-app/lib/widgets/badge.dart | import 'package:flutter/material.dart';
class Badge extends StatelessWidget {
const Badge({
Key key,
@required this.child,
@required this.value,
this.color,
this.textColor,
}) : super(key: key);
final Widget child;
final String value;
final Color color;
final Color textColor;
@override
Widget build(BuildContext context) {
return Stack(
alignment: Alignment.center,
children: [
child,
Positioned(
right: 8,
top: 8,
child: Container(
padding: EdgeInsets.all(2.0),
// color: Theme.of(context).accentColor,
decoration: BoxDecoration(
borderRadius: BorderRadius.circular(10.0),
color: color != null ? color : Theme.of(context).accentColor,
),
constraints: BoxConstraints(
minWidth: 16,
minHeight: 16,
),
child: Text(
value,
textAlign: TextAlign.center,
style: TextStyle(
fontSize: 10,
color: textColor,
),
),
),
)
],
);
}
}
| 0 |
mirrored_repositories/kryptonian-flutter-app/lib | mirrored_repositories/kryptonian-flutter-app/lib/widgets/orders_item.dart | import 'dart:math';
import 'package:flutter/material.dart';
import 'package:flutter_complete_guide/pallete/deepBlue.dart';
import 'package:flutter_complete_guide/providers/cart.dart' show CartItem;
import 'package:flutter_complete_guide/providers/light.dart';
import 'package:intl/intl.dart';
import 'package:provider/provider.dart';
class OrdersItem extends StatefulWidget {
final String id;
final double amount;
final List<CartItem> products;
final DateTime dateTime;
OrdersItem({
this.id,
this.amount,
this.products,
this.dateTime,
});
@override
State<OrdersItem> createState() => _OrdersItemState();
}
class _OrdersItemState extends State<OrdersItem> {
bool _showCardFlag = false;
void _showCardHandler() {
setState(() {
_showCardFlag = !_showCardFlag;
});
}
@override
Widget build(BuildContext context) {
return SingleChildScrollView(
child: AnimatedContainer(
duration: Duration(milliseconds: 250),
curve: Curves.decelerate,
height: _showCardFlag
? min(widget.products.length * 20 + 200, 250).toDouble()
: 110,
child: Card(
margin: EdgeInsets.all(15),
elevation: 10,
child: Column(
children: <Widget>[
ListTile(
leading: Icon(
Icons.add_shopping_cart,
size: 40,
//color: DeepBlue.kToDark,
color: Provider.of<Light>(context).themeDark
? Colors.lightBlueAccent
: DeepBlue.kToDark,
),
title: Text('\$${widget.amount.toStringAsFixed(2)}'),
subtitle: Text('${DateFormat.yMMMd().format(widget.dateTime)} '
'${DateFormat.Hm().format(widget.dateTime)}'),
trailing: IconButton(
icon: _showCardFlag
? Icon(
Icons.expand_less,
color: Provider.of<Light>(context).themeDark
? Colors.lightBlueAccent
: DeepBlue.kToDark,
)
: Icon(
Icons.expand_more,
color: Provider.of<Light>(context).themeDark
? Colors.lightBlueAccent
: DeepBlue.kToDark,
),
onPressed: _showCardHandler,
),
),
_showCardFlag
? _buildDetailsCard(context)
: _buildEmptyContent(context),
],
),
),
),
);
}
Widget _buildDetailsCard(BuildContext context) {
return Expanded(
flex: _showCardFlag ? 1 : 0,
child: Container(
height: min(widget.products.length * 10 + 100, 180).toDouble(),
width: double.infinity,
child: Card(
margin: EdgeInsets.all(10),
child: ListView.builder(
itemCount: widget.products.length,
itemBuilder: (context, index) => ListTile(
leading: Icon(
Icons.view_list_sharp,
color: Provider.of<Light>(context).themeDark
? Colors.lightBlueAccent
: DeepBlue.kToDark,
),
title: Text(widget.products[index].title),
trailing: Row(
mainAxisAlignment: MainAxisAlignment.end,
mainAxisSize: MainAxisSize.min,
children: <Widget>[
Icon(
Icons.shopping_cart,
color: Provider.of<Light>(context).themeDark
? Colors.lightBlueAccent
: DeepBlue.kToDark,
),
Container(
width: 25,
alignment: Alignment.centerLeft,
child: Text('${widget.products[index].quantity}x'),
),
SizedBox(width: 10),
Container(
width: 65,
alignment: Alignment.centerRight,
child: Text(
'\$${(widget.products[index].price * widget.products[index].quantity).toStringAsFixed(2)}'),
),
],
),
),
),
),
),
);
}
Widget _buildEmptyContent(BuildContext context) {
return Container();
}
}
| 0 |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.