Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
M
medapp_eksad
Project
Project
Details
Activity
Releases
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
qorri_di
medapp_eksad
Commits
41df0161
Commit
41df0161
authored
Sep 28, 2022
by
Tohap Maruli Pasaribu
Browse files
Options
Browse Files
Download
Plain Diff
Merge branch 'master' of
http://103.44.149.204/qorridi/medapp_eksad
into develop
parents
1ecf54e9
dfc1191d
Changes
5
Show whitespace changes
Inline
Side-by-side
Showing
5 changed files
with
505 additions
and
342 deletions
+505
-342
sosmed_api.dart
lib/api/sosmed_api.dart
+140
-2
user_api.dart
lib/api/user_api.dart
+1
-0
appbar_home.dart
lib/appbar/appbar_home.dart
+3
-0
admin_sosmed.dart
lib/dashboard/admin/admin_sosmed.dart
+324
-319
whatsapp.dart
lib/widget/whatsapp.dart
+37
-21
No files found.
lib/api/sosmed_api.dart
View file @
41df0161
...
...
@@ -26,10 +26,11 @@ Future<bool> createSosmed (wa, ln, tw, ig, yt) async{
}
}
Future
<
bool
>
updateSosmed
(
wa
,
ln
,
tw
,
ig
,
yt
)
async
{
Future
<
bool
>
updateSosmed
(
id
,
wa
,
ln
,
tw
,
ig
,
yt
)
async
{
final
response
=
await
http
.
p
ut
(
Uri
.
parse
(
'
$cmd
/settingsosmed/updat
eSettingSosmed'
),
.
p
ost
(
Uri
.
parse
(
'
$cmd
/settingsosmed/sav
eSettingSosmed'
),
body:
jsonEncode
({
'idSettingSosmed'
:
id
,
'whatsapp'
:
wa
,
'linkedin'
:
ln
,
'twitter'
:
tw
,
...
...
@@ -53,3 +54,140 @@ Future<List<dynamic>> getSosmedDesc() async {
Uri
.
parse
(
'
$qry
/settingsosmed/getSettingSosmedByIdDesc'
));
return
jsonDecode
(
response
.
body
)[
'data'
];
}
Future
<
bool
>
createWA
(
wa
)
async
{
final
response
=
await
http
.
post
(
Uri
.
parse
(
'
$cmd
/settingsosmed/saveWhatsapp'
),
body:
jsonEncode
(
{
"whatsapp"
:
wa
,
// "linkedin": ln,
// "twitter": tw,
// "instagram": ig,
// "youtube": yt,
}),
headers:
{
'Content-type'
:
'application/json; charset=UTF-8'
,
});
if
(
response
.
statusCode
==
200
)
{
return
true
;
}
else
{
return
false
;
}
}
Future
<
bool
>
createLN
(
ln
)
async
{
final
response
=
await
http
.
post
(
Uri
.
parse
(
'
$cmd
/settingsosmed/saveLinkedin'
),
body:
jsonEncode
(
{
// "whatsapp": wa,
"linkedin"
:
ln
,
// "twitter": tw,
// "instagram": ig,
// "youtube": yt,
}),
headers:
{
'Content-type'
:
'application/json; charset=UTF-8'
,
});
if
(
response
.
statusCode
==
200
)
{
return
true
;
}
else
{
return
false
;
}
}
Future
<
bool
>
createTW
(
tw
)
async
{
final
response
=
await
http
.
post
(
Uri
.
parse
(
'
$cmd
/settingsosmed/saveTwitter'
),
body:
jsonEncode
(
{
// "whatsapp": wa,
// "linkedin": ln,
"twitter"
:
tw
,
// "instagram": ig,
// "youtube": yt,
}),
headers:
{
'Content-type'
:
'application/json; charset=UTF-8'
,
});
if
(
response
.
statusCode
==
200
)
{
return
true
;
}
else
{
return
false
;
}
}
Future
<
bool
>
createIG
(
ig
)
async
{
final
response
=
await
http
.
post
(
Uri
.
parse
(
'
$cmd
/settingsosmed/saveInstagram'
),
body:
jsonEncode
(
{
// "whatsapp": wa,
// "linkedin": ln,
// "twitter": tw,
"instagram"
:
ig
,
// "youtube": yt,
}),
headers:
{
'Content-type'
:
'application/json; charset=UTF-8'
,
});
if
(
response
.
statusCode
==
200
)
{
return
true
;
}
else
{
return
false
;
}
}
Future
<
bool
>
createYT
(
yt
)
async
{
final
response
=
await
http
.
post
(
Uri
.
parse
(
'
$cmd
/settingsosmed/saveYoutube'
),
body:
jsonEncode
(
{
// "whatsapp": wa,
// "linkedin": ln,
// "twitter": tw,
// "instagram": ig,
"youtube"
:
yt
,
}),
headers:
{
'Content-type'
:
'application/json; charset=UTF-8'
,
});
if
(
response
.
statusCode
==
200
)
{
return
true
;
}
else
{
return
false
;
}
}
Future
<
List
<
dynamic
>>
getWaDesc
()
async
{
var
response
=
await
http
.
get
(
Uri
.
parse
(
'
$qry
/settingsosmed/getWhatsappByIdDesc'
));
return
jsonDecode
(
response
.
body
)[
'data'
];
}
Future
<
List
<
dynamic
>>
getLnDesc
()
async
{
var
response
=
await
http
.
get
(
Uri
.
parse
(
'
$qry
/settingsosmed/getLinkedinByIdDesc'
));
return
jsonDecode
(
response
.
body
)[
'data'
];
}
Future
<
List
<
dynamic
>>
getTwDesc
()
async
{
var
response
=
await
http
.
get
(
Uri
.
parse
(
'
$qry
/settingsosmed/getTwitterByIdDesc'
));
return
jsonDecode
(
response
.
body
)[
'data'
];
}
Future
<
List
<
dynamic
>>
getIgDesc
()
async
{
var
response
=
await
http
.
get
(
Uri
.
parse
(
'
$qry
/settingsosmed/getInstagramByIdDesc'
));
return
jsonDecode
(
response
.
body
)[
'data'
];
}
Future
<
List
<
dynamic
>>
getYtDesc
()
async
{
var
response
=
await
http
.
get
(
Uri
.
parse
(
'
$qry
/settingsosmed/getYoutubeByIdDesc'
));
return
jsonDecode
(
response
.
body
)[
'data'
];
}
\ No newline at end of file
lib/api/user_api.dart
View file @
41df0161
...
...
@@ -29,6 +29,7 @@ Future<bool> signUp(namars,nors,alamatrs,namapic,nopic,email, password)async{
}
// return response.statusCode;
}
Future
<
bool
>
signIn
(
username
,
password
)
async
{
final
response
=
await
http
.
post
(
Uri
.
parse
(
'
$cmd
/user/signin'
),
...
...
lib/appbar/appbar_home.dart
View file @
41df0161
import
'package:flutter/material.dart'
;
import
'package:medapp_eksad/firebase/firebase_auth_methods.dart'
;
import
'package:medapp_eksad/widget/button_appbar.dart'
;
import
'package:medapp_eksad/register.dart'
;
import
'package:provider/provider.dart'
;
AppBar
AppbarHomeLarge
(
Size
screenSize
,
BuildContext
context
,
Color
home
,
...
...
@@ -144,6 +146,7 @@ AppBar AppbarHomeLargeUser(Size screenSize, BuildContext context, Color home,
),
ElevatedButton
(
onPressed:
()
{
context
.
read
<
FirebaseAuthMethods
>().
signOut
(
context
);
Navigator
.
pushNamed
(
context
,
'/'
);
},
style:
ElevatedButton
.
styleFrom
(
...
...
lib/dashboard/admin/admin_sosmed.dart
View file @
41df0161
...
...
@@ -15,27 +15,30 @@ class _SosmedDashboardState extends State<SosmedDashboard> {
var
enb
=
true
;
final
formKey
=
GlobalKey
<
FormState
>();
TextEditingController
waController
=
new
TextEditingController
();
//
final waController = TextEditingController();
//
TextEditingController waController = new TextEditingController();
final
waController
=
TextEditingController
();
final
linkedController
=
TextEditingController
();
final
twitterController
=
TextEditingController
();
final
igController
=
TextEditingController
();
final
youtubeController
=
TextEditingController
();
String
wa
=
''
;
String
ln
=
''
;
String
tw
=
''
;
String
tw
=
''
;
String
ig
=
''
;
String
yt
=
''
;
String
pattern
=
r'(\62)(\d{2,3})?\)?[ .-]?\d{2,4}[ .-]?\d{2,4}[ .-]?\d{2,4}'
;
@override
Widget
build
(
BuildContext
context
)
{
var
screenSize
=
MediaQuery
.
of
(
context
).
size
;
return
Container
(
color:
const
Color
.
fromRGBO
(
238
,
224
,
224
,
1
),
padding:
EdgeInsets
.
symmetric
(
horizontal:
screenSize
.
width
*
0.
1
5
,
vertical:
screenSize
.
height
*
0.
15
),
horizontal:
screenSize
.
width
*
0.
0
5
,
vertical:
screenSize
.
height
*
0.
04
),
child:
Container
(
width:
screenSize
.
width
,
height:
screenSize
.
height
*
0.8
,
...
...
@@ -62,15 +65,37 @@ class _SosmedDashboardState extends State<SosmedDashboard> {
),
primary:
const
Color
.
fromARGB
(
255
,
0
,
67
,
192
),
),
onPressed:
()
{
onPressed:
()
async
{
switch
(
btnText
)
{
case
'Save Setting'
:
createSosmed
(
wa
,
ln
,
tw
,
ig
,
yt
);
{
ScaffoldMessenger
.
of
(
context
).
showSnackBar
(
SnackBar
(
content:
Text
(
'Save Data Success'
),
));
if
(
formKey
.
currentState
!.
validate
())
{
// await updateSosmed(wa, ln, tw, ig, yt);
// await createSosmed(wa, ln, tw, ig, yt);
await
createWA
(
wa
);
await
createLN
(
ln
);
await
createTW
(
tw
);
await
createIG
(
ig
);
await
createYT
(
yt
);
ScaffoldMessenger
.
of
(
context
).
showSnackBar
(
const
SnackBar
(
content:
Text
(
'Data Saved'
),
backgroundColor:
Colors
.
green
)
);
}
else
if
(
formKey
.
currentState
!.
validate
()){}
else
{
ScaffoldMessenger
.
of
(
context
).
showSnackBar
(
const
SnackBar
(
content:
Text
(
'Failed to save data, please edit all field'
),
backgroundColor:
Colors
.
red
)
);
}
// waController.clear();
// linkedController.clear();
// twitterController.clear();
...
...
@@ -81,7 +106,9 @@ class _SosmedDashboardState extends State<SosmedDashboard> {
setState
(()
{
btnText
=
'Update Setting'
;
enb
=
false
;
});
}
);
break
;
case
'Update Setting'
:
// waController.clear();
...
...
@@ -95,20 +122,35 @@ class _SosmedDashboardState extends State<SosmedDashboard> {
});
break
;
case
'Save Update'
:
createSosmed
(
wa
,
ln
,
tw
,
ig
,
yt
);
{
ScaffoldMessenger
.
of
(
context
).
showSnackBar
(
SnackBar
(
content:
Text
(
'Save Data Success'
),
));
if
(
formKey
.
currentState
!.
validate
())
{
// await updateSosmed(wa, ln, tw, ig, yt);
// await createSosmed(wa, ln, tw, ig, yt);
await
createWA
(
wa
);
await
createLN
(
ln
);
await
createTW
(
tw
);
await
createIG
(
ig
);
await
createYT
(
yt
);
ScaffoldMessenger
.
of
(
context
).
showSnackBar
(
const
SnackBar
(
content:
Text
(
'Data Saved'
),
backgroundColor:
Colors
.
green
)
);
}
else
if
(
formKey
.
currentState
!.
validate
()){}
else
{
ScaffoldMessenger
.
of
(
context
).
showSnackBar
(
const
SnackBar
(
content:
Text
(
'Failed to save data, please edit all field'
),
backgroundColor:
Colors
.
red
)
);
}
break
;
default
:
createSosmed
(
wa
,
ln
,
tw
,
ig
,
yt
);
{
ScaffoldMessenger
.
of
(
context
).
showSnackBar
(
SnackBar
(
content:
Text
(
'Save Data Success'
),
));
}
}
},
child:
Text
(
...
...
@@ -126,303 +168,266 @@ class _SosmedDashboardState extends State<SosmedDashboard> {
// endIndent: 0,
color:
Colors
.
grey
,
),
SizedBox
(
height:
25
,
// Text('Data Must Be Edited'),
// Text('For data that is not modified, Please copy last data , delete then paste again'),
const
SizedBox
(
height:
10
,
),
FutureBuilder
(
future:
getSosmedDesc
(),
// FutureBuilder<List<dynamic>>(
// future: getSosmedDesc(),
// builder: (BuildContext context, AsyncSnapshot snapshot) {
// var pgm = snapshot.data[0];
//
// if (snapshot.hasError ||
// snapshot.data == null ||
// snapshot.connectionState == ConnectionState.waiting) {
// return const CircularProgressIndicator();
// }
// return
// },
// ),
Column
(
mainAxisAlignment:
MainAxisAlignment
.
spaceBetween
,
children:
[
FutureBuilder
<
List
<
dynamic
>>(
future:
getWaDesc
(),
builder:
(
BuildContext
context
,
AsyncSnapshot
snapshot
)
{
var
pgm
=
snapshot
.
data
[
0
];
final
waController
=
TextEditingController
();
final
linkedController
=
TextEditingController
();
final
twitterController
=
TextEditingController
();
final
igController
=
TextEditingController
();
final
youtubeController
=
TextEditingController
();
if
(
snapshot
.
hasError
||
snapshot
.
data
==
null
||
snapshot
.
connectionState
==
ConnectionState
.
waiting
)
{
return
const
CircularProgressIndicator
();
}
return
Column
(
mainAxisAlignment:
MainAxisAlignment
.
spaceBetween
,
children:
[
listsosmed
(
Icon
(
return
listsosmed
(
const
Icon
(
Icons
.
whatsapp
,
color:
Colors
.
green
,
),
TextFormField
(
// controller: waController,
initialValue:
pgm
[
'whatsapp'
],
decoration:
InputDecoration
(
controller:
waController
..
text
=
pgm
[
'whatsapp'
],
//initialValue: pgm['whatsapp'],
decoration:
const
InputDecoration
(
errorStyle:
TextStyle
(
color:
Colors
.
red
),
hintText:
'Enter WhatsApp number without +, Ex : 6280000000000 '
),
'Enter WhatsApp number without +, Ex : 6280000000000 '
,
helperText:
'Enter WhatsApp number without +, Ex : 6280000000000 '
,
),
onChanged:
(
value
)
=>
wa
=
value
,
enabled:
enb
,
validator:
(
value
)
{
if
(
value
==
null
||
value
.
isEmpty
)
{
return
'Please enter your phone number'
;
}
else
if
(!
RegExp
(
pattern
).
hasMatch
(
value
)){
return
'Please enter with 628 only'
;
}
return
null
;
},
),
// ElevatedButton(
// onPressed: () {
// showDialog(
// context: context,
// builder: (BuildContext context) => AlertDialog(
// content: FutureBuilder<List<dynamic>>(
// future: getSosmedDesc(),
// builder: (BuildContext context,
// AsyncSnapshot snapshot) {
// var pgm = snapshot.data[0];
// if (snapshot.hasError ||
// snapshot.data == null ||
// snapshot.connectionState ==
// ConnectionState.waiting) {
// return const CircularProgressIndicator();
// }
// return Text(
// 'Active WA : ' + pgm['whatsapp']);
// },
// ),
// ),
// );
// },
// child: Text('View Active'),
// ),
ElevatedButton
(
onPressed:
()
{
showDialog
(
context:
context
,
builder:
(
BuildContext
context
)
=>
AlertDialog
(
content:
Text
(
'Active WA : '
+
pgm
[
'whatsapp'
],
),
),
builder:
(
BuildContext
context
)=>
AlertDialog
(
content:
Text
(
'Active WA : '
+
pgm
[
'whatsapp'
])
)
,
);
},
child:
const
Text
(
'View Active'
)));
},
child:
Text
(
'View Active'
),
),
),
SizedBox
(
const
SizedBox
(
height:
10
,
),
listsosmed
(
Icon
(
FutureBuilder
<
List
<
dynamic
>>(
future:
getLnDesc
(),
builder:
(
BuildContext
context
,
AsyncSnapshot
snapshot
)
{
var
pgm
=
snapshot
.
data
[
0
];
if
(
snapshot
.
hasError
||
snapshot
.
data
==
null
||
snapshot
.
connectionState
==
ConnectionState
.
waiting
)
{
return
const
CircularProgressIndicator
();
}
return
listsosmed
(
const
Icon
(
FontAwesomeIcons
.
linkedin
,
color:
Colors
.
blue
,
),
TextFormField
(
// controller: linkedController,
initialValue:
pgm
[
'linkedin'
],
decoration:
InputDecoration
(
controller:
linkedController
..
text
=
pgm
[
'linkedin'
],
//initialValue: pgm['linkedin'],
decoration:
const
InputDecoration
(
errorStyle:
TextStyle
(
color:
Colors
.
red
),
hintText:
'Enter a new Linkedin link address'
),
onChanged:
(
value
)
=>
ln
=
value
,
enabled:
enb
,
validator:
(
value
)
{
if
(
value
==
null
||
value
.
isEmpty
)
{
return
'Please enter linkedin link'
;
}
return
null
;
},
),
// ElevatedButton(
// onPressed: () {
// showDialog(
// context: context,
// builder: (BuildContext context) => AlertDialog(
// content: FutureBuilder<List<dynamic>>(
// future: getSosmedDesc(),
// builder: (BuildContext context,
// AsyncSnapshot snapshot) {
// var pgm = snapshot.data[0];
// if (snapshot.hasError ||
// snapshot.data == null ||
// snapshot.connectionState ==
// ConnectionState.waiting) {
// return const CircularProgressIndicator();
// }
// return Text('Active Linkedin : ' +
// pgm['linkedin']);
// },
// ),
// ),
// );
// },
// child: Text('View Active'),
// ),
ElevatedButton
(
onPressed:
()
{
showDialog
(
context:
context
,
builder:
(
BuildContext
context
)
=>
AlertDialog
(
content:
Text
(
'Active Linkedin : '
+
pgm
[
'linkedin'
],
),
),
builder:
(
BuildContext
context
)=>
AlertDialog
(
content:
Text
(
'Active Linkedin : '
+
pgm
[
'linkedin'
])
)
,
);
},
child:
const
Text
(
'View Active'
)));
},
child:
Text
(
'View Active'
),
),
),
SizedBox
(
const
SizedBox
(
height:
10
,
),
listsosmed
(
Icon
(
FutureBuilder
<
List
<
dynamic
>>(
future:
getTwDesc
(),
builder:
(
BuildContext
context
,
AsyncSnapshot
snapshot
)
{
var
pgm
=
snapshot
.
data
[
0
];
if
(
snapshot
.
hasError
||
snapshot
.
data
==
null
||
snapshot
.
connectionState
==
ConnectionState
.
waiting
)
{
return
const
CircularProgressIndicator
();
}
return
listsosmed
(
const
Icon
(
FontAwesomeIcons
.
twitterSquare
,
color:
Colors
.
blueAccent
,
),
TextFormField
(
// controller: twitterController,
initialValue:
pgm
[
'twitter'
],
decoration:
InputDecoration
(
controller:
twitterController
..
text
=
pgm
[
'twitter'
],
//initialValue: pgm['twitter'],
decoration:
const
InputDecoration
(
errorStyle:
TextStyle
(
color:
Colors
.
red
),
hintText:
'Enter a new Twitter link address'
),
onChanged:
(
value
)
=>
tw
=
value
,
enabled:
enb
,
validator:
(
value
)
{
if
(
value
==
null
||
value
.
isEmpty
)
{
return
'Please enter twitter link'
;
}
return
null
;
},
),
// ElevatedButton(
// onPressed: () {
// showDialog(
// context: context,
// builder: (BuildContext context) => AlertDialog(
// content: FutureBuilder<List<dynamic>>(
// future: getSosmedDesc(),
// builder: (BuildContext context,
// AsyncSnapshot snapshot) {
// var pgm = snapshot.data[0];
// if (snapshot.hasError ||
// snapshot.data == null ||
// snapshot.connectionState ==
// ConnectionState.waiting) {
// return const CircularProgressIndicator();
// }
// return Text(
// 'Active Twitter : ' + pgm['twitter']);
// },
// ),
// ),
// );
// },
// child: Text('View Active'),
// ),
ElevatedButton
(
onPressed:
()
{
showDialog
(
context:
context
,
builder:
(
BuildContext
context
)
=>
AlertDialog
(
content:
Text
(
'Active Twitter : '
+
pgm
[
'twitter'
],
),
),
builder:
(
BuildContext
context
)=>
AlertDialog
(
content:
Text
(
'Active Twitter : '
+
pgm
[
'twitter'
])
)
,
);
},
child:
const
Text
(
'View Active'
)));
},
child:
Text
(
'View Active'
),
),
),
SizedBox
(
const
SizedBox
(
height:
10
,
),
listsosmed
(
Icon
(
FutureBuilder
<
List
<
dynamic
>>(
future:
getIgDesc
(),
builder:
(
BuildContext
context
,
AsyncSnapshot
snapshot
)
{
var
pgm
=
snapshot
.
data
[
0
];
if
(
snapshot
.
hasError
||
snapshot
.
data
==
null
||
snapshot
.
connectionState
==
ConnectionState
.
waiting
)
{
return
const
CircularProgressIndicator
();
}
return
listsosmed
(
const
Icon
(
FontAwesomeIcons
.
instagramSquare
,
color:
Colors
.
pink
,
),
TextFormField
(
// controller: igController,
initialValue:
pgm
[
'instagram'
],
decoration:
InputDecoration
(
controller:
igController
..
text
=
pgm
[
'instagram'
],
// initialValue: pgm['instagram'],
decoration:
const
InputDecoration
(
errorStyle:
TextStyle
(
color:
Colors
.
red
),
hintText:
'Enter a new Instagram link address'
),
onChanged:
(
value
)
=>
ig
=
value
,
enabled:
enb
,
validator:
(
value
)
{
if
(
value
==
null
||
value
.
isEmpty
)
{
return
'Please enter instagram link'
;
}
return
null
;
},
),
// ElevatedButton(
// onPressed: () {
// showDialog(
// context: context,
// builder: (BuildContext context) => AlertDialog(
// content: FutureBuilder<List<dynamic>>(
// future: getSosmedDesc(),
// builder: (BuildContext context,
// AsyncSnapshot snapshot) {
// var pgm = snapshot.data[0];
// if (snapshot.hasError ||
// snapshot.data == null ||
// snapshot.connectionState ==
// ConnectionState.waiting) {
// return const CircularProgressIndicator();
// }
// return Text('Active Instagram : ' +
// pgm['instagram']);
// },
// ),
// ),
// );
// },
// child: Text('View Active'),
// ),
ElevatedButton
(
onPressed:
()
{
showDialog
(
context:
context
,
builder:
(
BuildContext
context
)
=>
AlertDialog
(
content:
Text
(
'Active Instagram : '
+
pgm
[
'instagram'
],
),
),
builder:
(
BuildContext
context
)=>
AlertDialog
(
content:
Text
(
'Active Instagram : '
+
pgm
[
'instagram'
])
)
,
);
},
child:
const
Text
(
'View Active'
)));
},
child:
Text
(
'View Active'
),
),
),
SizedBox
(
const
SizedBox
(
height:
10
,
),
listsosmed
(
Icon
(
FutureBuilder
<
List
<
dynamic
>>(
future:
getYtDesc
(),
builder:
(
BuildContext
context
,
AsyncSnapshot
snapshot
)
{
var
pgm
=
snapshot
.
data
[
0
];
if
(
snapshot
.
hasError
||
snapshot
.
data
==
null
||
snapshot
.
connectionState
==
ConnectionState
.
waiting
)
{
return
const
CircularProgressIndicator
();
}
return
listsosmed
(
const
Icon
(
FontAwesomeIcons
.
youtube
,
color:
Colors
.
red
,
),
TextFormField
(
// controller: youtubeController,
initialValue:
pgm
[
'youtube'
],
decoration:
InputDecoration
(
controller:
youtubeController
..
text
=
pgm
[
'youtube'
],
//initialValue: pgm['youtube'],
decoration:
const
InputDecoration
(
errorStyle:
TextStyle
(
color:
Colors
.
red
),
hintText:
'Enter a new Youtube link address'
),
onChanged:
(
value
)
=>
yt
=
value
,
enabled:
enb
,
validator:
(
value
)
{
if
(
value
==
null
||
value
.
isEmpty
)
{
return
'Please enter youtube link'
;
}
return
null
;
},
),
// ElevatedButton(
// onPressed: () {
// showDialog(
// context: context,
// builder: (BuildContext context) => AlertDialog(
// content: FutureBuilder<List<dynamic>>(
// future: getSosmedDesc(),
// builder: (BuildContext context,
// AsyncSnapshot snapshot) {
// var pgm = snapshot.data[0];
// if (snapshot.hasError ||
// snapshot.data == null ||
// snapshot.connectionState ==
// ConnectionState.waiting) {
// return const CircularProgressIndicator();
// }
// return Text(
// 'Active Youtube : ' + pgm['youtube']);
// },
// ),
// ),
// );
// },
// child: Text('View Active'),
// ),
ElevatedButton
(
onPressed:
()
{
showDialog
(
context:
context
,
builder:
(
BuildContext
context
)
=>
AlertDialog
(
content:
Text
(
'Active Youtube : '
+
pgm
[
'youtube'
],
),
),
builder:
(
BuildContext
context
)=>
AlertDialog
(
content:
Text
(
'Active Youtube : '
+
pgm
[
'youtube'
])
)
,
);
},
child:
const
Text
(
'View Active'
)));
},
child:
Text
(
'View Active'
),
),
),
],
);
}),
),
],
),
),
...
...
lib/widget/whatsapp.dart
View file @
41df0161
import
'package:flutter/material.dart'
;
import
'package:medapp_eksad/api/sosmed_api.dart'
;
import
'package:url_launcher/url_launcher.dart'
;
import
'package:spring/spring.dart'
;
...
...
@@ -6,7 +7,7 @@ class WAChat extends StatelessWidget {
WAChat
({
Key
?
key
})
:
super
(
key:
key
);
void
launchWhatsApp
({
required
final
int
phone
,
required
final
String
phone
,
required
String
message
,
})
async
{
String
url
()
{
...
...
@@ -22,19 +23,32 @@ class WAChat extends StatelessWidget {
final
SpringController
springController
=
SpringController
(
initialAnim:
Motion
.
play
);
String
wa
=
''
;
@override
Widget
build
(
BuildContext
context
)
{
return
FloatingActionButton
(
onPressed:
()
{},
backgroundColor:
Colors
.
green
,
onPressed:
(){
child:
FutureBuilder
<
List
<
dynamic
>>(
future:
getSosmedDesc
(),
builder:
(
BuildContext
context
,
AsyncSnapshot
snapshot
)
{
var
pgm
=
snapshot
.
data
[
0
];
if
(
snapshot
.
hasError
||
snapshot
.
data
==
null
||
snapshot
.
connectionState
==
ConnectionState
.
waiting
)
{
return
const
CircularProgressIndicator
();
}
return
GestureDetector
(
onTap:
()
{
wa
=
pgm
[
'whatsapp'
];
springController
.
play
(
motion:
Motion
.
reverse
,
animDuration:
const
Duration
(
milliseconds:
1000
),
curve:
Curves
.
easeInBack
,
delay:
const
Duration
(
milliseconds:
100
));
launchWhatsApp
(
phone:
6287701892981
,
phone:
wa
,
message:
'Hallo, saya tertarik dan saya ingin tahu lebih lanjut tentang program Medapp dari EKSAD'
);
},
...
...
@@ -44,9 +58,11 @@ class WAChat extends StatelessWidget {
springController:
springController
,
alignment:
Alignment
.
center
,
animStatus:
(
AnimStatus
status
)
{},
child:
const
Icon
(
Icons
.
whatsapp
,
size:
40
,
color:
Colors
.
white
,),
child:
const
Icon
(
Icons
.
whatsapp
,
size:
30
),
),
);
},
),
);
}
}
//phone: 81807890777,
\ No newline at end of file
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment