Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- import 'package:ayo_sholat/const/date.dart';
- import 'package:ayo_sholat/services/notif.dart';
- import 'package:flutter/material.dart';
- import 'package:flutter_local_notifications/flutter_local_notifications.dart';
- import 'package:material_design_icons_flutter/material_design_icons_flutter.dart';
- void main(){
- runApp(MyApp());
- }
- class MyApp extends StatelessWidget {
- // This widget is the root of your application.
- @override
- Widget build(BuildContext context) {
- return MaterialApp(
- home: MyHomePage(),
- );
- }
- }
- class MyHomePage extends StatefulWidget {
- @override
- _MyHomePageState createState() => _MyHomePageState();
- }
- class _MyHomePageState extends State<MyHomePage> {
- Date date = Date();
- Notif notif = Notif();
- FlutterLocalNotificationsPlugin localNotificationsPlugin;
- var now = new DateTime.now();
- var date1 = DateTime.parse("2019-09-07 22:36:00");
- @override
- void initState() {
- super.initState();
- var initAndroid = new AndroidInitializationSettings('app_icon');
- var initIos = new IOSInitializationSettings();
- var initSettings = new InitializationSettings(initAndroid, initIos);
- localNotificationsPlugin = new FlutterLocalNotificationsPlugin();
- localNotificationsPlugin.initialize(initSettings);
- }
- showNotification(FlutterLocalNotificationsPlugin flutterLocalNotificationsPlugin) async{
- var time = new Time(8, 38, 0);
- var androidPlatformChannelSpecifics =
- new AndroidNotificationDetails('12',
- 'Ayo Sholat', 'Ayo Sholat');
- var iOSPlatformChannelSpecifics =
- new IOSNotificationDetails();
- var platformChannelSpecifics = new NotificationDetails(
- androidPlatformChannelSpecifics, iOSPlatformChannelSpecifics);
- await flutterLocalNotificationsPlugin.showDailyAtTime(
- 0,
- 'show daily title',
- 'Daily notification shown at approximately ',
- time,
- platformChannelSpecifics);
- }
- @override
- Widget build(BuildContext context) {
- return Scaffold(
- backgroundColor: Colors.white,
- body: SingleChildScrollView(
- child: Column(
- children: <Widget>[
- Stack(
- children: <Widget>[
- Container(
- width: double.infinity,
- height: MediaQuery.of(context).size.height / 2,
- decoration: BoxDecoration(
- color: Colors.grey[300],
- image: DecorationImage(
- image: NetworkImage("https://cdn.dribbble.com/users/1866105/screenshots/3766355/1.jpg"),
- fit: BoxFit.cover
- )
- ),
- ),
- Padding(
- padding: const EdgeInsets.only(
- top: 48.0
- ),
- child: Row(
- mainAxisAlignment: MainAxisAlignment.center,
- crossAxisAlignment: CrossAxisAlignment.center,
- children: <Widget>[
- Column(
- children: <Widget>[
- Text("Dhuhur 12:13", style: TextStyle(fontSize: 32.0, fontWeight: FontWeight.w600, color: Colors.white),),
- SizedBox(height: 8.0,),
- Text("3 Jam 45 Menit Lagi", style: TextStyle(fontSize: 20.0, fontWeight: FontWeight.w500, color: Colors.white),),
- ],
- )
- ],
- ),
- ),
- Positioned(
- left: 0,
- bottom: 0,
- child: Padding(
- padding: EdgeInsets.only(
- left: 24.0,
- bottom: 24.0
- ),
- child: Column(
- mainAxisAlignment: MainAxisAlignment.start,
- crossAxisAlignment: CrossAxisAlignment.start,
- children: <Widget>[
- Text("Hari Ini", style: TextStyle(color: Colors.white, fontSize: 28.0),),
- SizedBox(height: 4.0,),
- Text("${date.hari[now.weekday - 1]}, ${now.day} ${date.bulan[now.month - 1]} ${now.year}", style: TextStyle(color: Colors.white, fontSize: 18.0),),
- ],
- ),
- ),
- )
- ],
- ),
- Padding(
- padding: const EdgeInsets.symmetric(
- horizontal: 24.0
- ),
- child: Container(
- width: double.infinity,
- height: MediaQuery.of(context).size.height / 2,
- child: ListView.builder(
- itemCount: date.sholat.length,
- itemBuilder: (context, index){
- return Row(
- children: <Widget>[
- Expanded(flex: 1,child: Text("${date.sholat[index]}", style: TextStyle(fontSize: 20.0),)),
- Expanded(flex: 2, child: Center(child: Text("12:13", style: TextStyle(fontSize: 20.0),))),
- Expanded(
- flex: 1,
- child: IconButton(
- onPressed: () {
- showNotification(localNotificationsPlugin);
- },
- icon: Icon(MdiIcons.alarm, size: 28.0,),
- ),
- )
- ],
- );
- },
- ),
- ),
- )
- ],
- ),
- ),
- );
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement