Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Contribute to GitLab
Sign in
Toggle navigation
S
second_display
Project
Project
Details
Activity
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
Dio Maulana
second_display
Commits
90dd4942
Commit
90dd4942
authored
Mar 18, 2022
by
Dio Maulana
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
fix error base url
parent
e617db44
Show whitespace changes
Inline
Side-by-side
Showing
19 changed files
with
566 additions
and
130 deletions
+566
-130
build.gradle
android/app/build.gradle
+1
-1
error.png
assets/images/error.png
+0
-0
api.dart
lib/api/api.dart
+9
-4
config_display_blog.dart
lib/bloc/config_display_blog.dart
+4
-4
config.dart
lib/helper/config.dart
+9
-14
main.dart
lib/main.dart
+9
-0
config_display.dart
lib/models/config_display.dart
+11
-2
carousel.dart
lib/ui/carousel.dart
+25
-22
error.dart
lib/ui/error.dart
+79
-0
input_base_url.dart
lib/ui/input_base_url.dart
+65
-0
main_page.dart
lib/ui/main_page.dart
+66
-47
orders.dart
lib/ui/orders.dart
+5
-5
splash.dart
lib/ui/splash.dart
+36
-17
video_promotion.dart
lib/ui/video_promotion.dart
+3
-3
youtube.dart
lib/ui/youtube.dart
+61
-10
pubspec.lock
pubspec.lock
+176
-1
pubspec.yaml
pubspec.yaml
+3
-0
generated_plugin_registrant.cc
windows/flutter/generated_plugin_registrant.cc
+3
-0
generated_plugins.cmake
windows/flutter/generated_plugins.cmake
+1
-0
No files found.
android/app/build.gradle
View file @
90dd4942
...
...
@@ -44,7 +44,7 @@ android {
defaultConfig
{
// TODO: Specify your own unique Application ID (https://developer.android.com/studio/build/application-id.html).
applicationId
"com.example.second_display"
minSdkVersion
flutter
.
minSdkVersion
minSdkVersion
21
targetSdkVersion
flutter
.
targetSdkVersion
versionCode
flutterVersionCode
.
toInteger
()
versionName
flutterVersionName
...
...
assets/images/error.png
0 → 100644
View file @
90dd4942
826 KB
lib/api/api.dart
View file @
90dd4942
import
'dart:convert'
;
import
'package:second_display/helper/config.dart'
;
import
'package:second_display/main.dart'
;
import
'package:second_display/models/config_display.dart'
;
import
'package:second_display/models/order_detail.dart'
;
import
'package:second_display/models/orders.dart'
;
...
...
@@ -137,14 +138,17 @@ class Api {
}
}
static
Future
<
List
<
ConfigDisplay
>>
getConfigDisplay
()
async
{
String
apiUrl
=
apiUrlConfig
;
List
<
ConfigDisplay
>
configList
=
[];
static
Future
<
List
<
ConfigDisplay
>>
getConfigDisplay
({
url
=
''
})
async
{
String
apiUrl
=
url
+
apiUrlConfig
;
try
{
List
<
ConfigDisplay
>
configList
=
[];
Map
data
=
{};
var
bodi
=
jsonEncode
(
data
);
var
apiresults
=
await
http
.
post
(
Uri
.
parse
(
apiUrl
),
body:
bodi
);
if
(
apiresults
.
statusCode
!=
200
)
{
navigatorKey
.
currentState
?.
pushNamed
(
'/error'
);
}
var
jsonObject
=
jsonDecode
(
apiresults
.
body
);
List
<
dynamic
>
listConfig
=
(
jsonObject
as
Map
<
dynamic
,
dynamic
>)[
'data'
];
...
...
@@ -155,7 +159,8 @@ class Api {
return
configList
;
}
catch
(
e
)
{
return
[];
navigatorKey
.
currentState
?.
pushNamed
(
'/error'
);
throw
Exception
(
"Error to connect API
$e
"
);
}
}
}
lib/bloc/config_display_blog.dart
View file @
90dd4942
...
...
@@ -5,13 +5,13 @@ import 'package:bloc/bloc.dart';
class
ConfigDisplayBloc
extends
Cubit
<
List
<
ConfigDisplay
>>
{
ConfigDisplayBloc
()
:
super
([]);
Future
<
List
<
ConfigDisplay
>>
getData
()
async
{
var
orderDetail
=
await
Api
.
getConfigDisplay
();
Future
<
List
<
ConfigDisplay
>>
getData
(
String
url
)
async
{
var
orderDetail
=
await
Api
.
getConfigDisplay
(
url:
url
);
return
orderDetail
;
}
void
getConfigDisplay
()
{
getData
().
then
((
value
)
{
void
getConfigDisplay
(
String
url
)
{
getData
(
url
).
then
((
value
)
{
emit
(
value
);
});
}
...
...
lib/helper/config.dart
View file @
90dd4942
import
'package:
flutter/material
.dart'
;
import
'package:
second_display/main
.dart'
;
import
'package:second_display/models/orders.dart'
;
// final Color textColor = Colors.white;
// final Color colorBackgroundOrder = Colors.black.withOpacity(0.8);
final
String
getOrdersUrl
=
"http://192.168.2.142:8001/midware/order/get_by_id"
;
final
String
apiUrlConfig
=
"http://192.168.2.142:8001/queue/config_second_display"
;
final
String
getJsonUrl
=
"http://192.168.2.142:8001/midware/order/get_for_second_display"
;
final
String
?
baseUrls
=
prefs
.
getString
(
'base_url'
);
final
String
urlDefault
=
''
;
late
String
baseUrl
=
baseUrls
??
urlDefault
;
final
String
getOrdersUrl
=
baseUrl
+
"midware/order/get_by_id"
;
final
String
apiUrlConfig
=
"queue/config_second_display"
;
final
String
getJsonUrl
=
baseUrl
+
"midware/order/get_for_second_display"
;
late
CustomerOrders
modelCustomerOrder
=
CustomerOrders
(
id:
""
,
total:
""
,
...
...
@@ -21,11 +22,5 @@ late CustomerOrders modelCustomerOrder = CustomerOrders(
dateOrder:
""
,
order_user_name:
""
);
final
List
<
String
>
imgList
=
[
'https://images.unsplash.com/photo-1520342868574-5fa3804e551c?ixlib=rb-0.3.5&ixid=eyJhcHBfaWQiOjEyMDd9&s=6ff92caffcdd63681a35134a6770ed3b&auto=format&fit=crop&w=1951&q=80'
,
'https://images.unsplash.com/photo-1522205408450-add114ad53fe?ixlib=rb-0.3.5&ixid=eyJhcHBfaWQiOjEyMDd9&s=368f45b0888aeb0b7b08e3a1084d3ede&auto=format&fit=crop&w=1950&q=80'
,
'https://images.unsplash.com/photo-1519125323398-675f0ddb6308?ixlib=rb-0.3.5&ixid=eyJhcHBfaWQiOjEyMDd9&s=94a1e718d89ca60a6337a6008341ca50&auto=format&fit=crop&w=1950&q=80'
,
'https://images.unsplash.com/photo-1523205771623-e0faa4d2813d?ixlib=rb-0.3.5&ixid=eyJhcHBfaWQiOjEyMDd9&s=89719a0d55dd05e2deae4120227e6efc&auto=format&fit=crop&w=1953&q=80'
,
'https://images.unsplash.com/photo-1508704019882-f9cf40e475b4?ixlib=rb-0.3.5&ixid=eyJhcHBfaWQiOjEyMDd9&s=8c6e5e3aba713b17aa1fe71ab4f0ae5b&auto=format&fit=crop&w=1352&q=80'
,
'https://images.unsplash.com/photo-1519985176271-adb1088fa94c?ixlib=rb-0.3.5&ixid=eyJhcHBfaWQiOjEyMDd9&s=a0c8d632e977f94e5d312d9893258f59&auto=format&fit=crop&w=1355&q=80'
];
final
List
<
String
>?
imgLists
=
prefs
.
getStringList
(
'imageList'
);
final
List
<
String
>
imglist
=
imgLists
!;
lib/main.dart
View file @
90dd4942
...
...
@@ -3,12 +3,18 @@ import 'package:flutter_bloc/flutter_bloc.dart';
import
'package:second_display/bloc/config_display_blog.dart'
;
import
'package:second_display/bloc/order_detail.dart'
;
import
'package:second_display/bloc/orders_bloc.dart'
;
import
'package:second_display/ui/error.dart'
;
import
'package:second_display/ui/input_base_url.dart'
;
import
'package:second_display/ui/main_page.dart'
;
import
'package:second_display/ui/splash.dart'
;
import
'package:shared_preferences/shared_preferences.dart'
;
import
'package:url_strategy/url_strategy.dart'
;
late
SharedPreferences
prefs
;
final
GlobalKey
<
NavigatorState
>
navigatorKey
=
GlobalKey
<
NavigatorState
>();
void
main
(
)
async
{
WidgetsFlutterBinding
.
ensureInitialized
();
prefs
=
await
SharedPreferences
.
getInstance
();
setPathUrlStrategy
();
runApp
(
const
MyApp
());
}
...
...
@@ -27,10 +33,13 @@ class MyApp extends StatelessWidget {
],
child:
MaterialApp
(
debugShowCheckedModeBanner:
false
,
navigatorKey:
navigatorKey
,
initialRoute:
'/'
,
routes:
{
'/'
:
(
context
)
=>
Splash
(),
'/main'
:
(
context
)
=>
MainPage
(),
'/error'
:
(
context
)
=>
ErrorPage
(),
'/inputbase'
:
(
context
)
=>
const
InputBaseUrl
()
},
),
);
...
...
lib/models/config_display.dart
View file @
90dd4942
...
...
@@ -3,12 +3,18 @@ class ConfigDisplay {
final
String
textColor
;
final
String
backgroundColorOrder
;
final
String
mediaType
;
final
String
youtubeId
;
final
String
videoPromotionUrl
;
final
String
images
;
ConfigDisplay
(
{
required
this
.
backgroundColorCarouselVideo
,
required
this
.
textColor
,
required
this
.
backgroundColorOrder
,
required
this
.
mediaType
});
required
this
.
mediaType
,
required
this
.
youtubeId
,
required
this
.
videoPromotionUrl
,
required
this
.
images
});
factory
ConfigDisplay
.
createConfig
(
Map
<
String
,
dynamic
>
json
)
{
return
ConfigDisplay
(
...
...
@@ -16,6 +22,9 @@ class ConfigDisplay {
json
[
'background_color_carousel_video'
].
toString
(),
textColor:
json
[
'text_color'
].
toString
(),
backgroundColorOrder:
json
[
'background_color_order'
],
mediaType:
json
[
'media_type'
]);
mediaType:
json
[
'media_type'
],
youtubeId:
json
[
'youtube_id'
],
videoPromotionUrl:
json
[
'video_promotion_url'
],
images:
json
[
'images'
]);
}
}
lib/ui/carousel.dart
View file @
90dd4942
...
...
@@ -13,8 +13,7 @@ class CarouselIndicator extends StatefulWidget {
class
_CarouselIndicatorState
extends
State
<
CarouselIndicator
>
{
int
_current
=
0
;
final
CarouselController
_controller
=
CarouselController
();
final
List
<
Widget
>
imageSliders
=
imgList
final
List
<
Widget
>
imageSliders
=
imglist
.
map
((
item
)
=>
Column
(
mainAxisAlignment:
MainAxisAlignment
.
center
,
children:
[
...
...
@@ -65,7 +64,7 @@ class _CarouselIndicatorState extends State<CarouselIndicator> {
items:
imageSliders
,
carouselController:
_controller
,
options:
CarouselOptions
(
autoPlay:
tru
e
,
autoPlay:
(
imglist
.
length
>
1
)
?
true
:
fals
e
,
autoPlayInterval:
const
Duration
(
seconds:
5
),
enlargeCenterPage:
true
,
viewportFraction:
1.0
,
...
...
@@ -77,25 +76,29 @@ class _CarouselIndicatorState extends State<CarouselIndicator> {
}),
),
),
Row
(
(
imgLists
!.
length
>
1
)
?
Row
(
mainAxisAlignment:
MainAxisAlignment
.
center
,
children:
imgL
ist
.
asMap
().
entries
.
map
((
entry
)
{
children:
imgl
ist
.
asMap
().
entries
.
map
((
entry
)
{
return
GestureDetector
(
onTap:
()
=>
_controller
.
animateToPage
(
entry
.
key
),
child:
Container
(
width:
MediaQuery
.
of
(
context
).
size
.
width
*
0.012
,
height:
MediaQuery
.
of
(
context
).
size
.
height
*
0.012
,
margin:
EdgeInsets
.
symmetric
(
vertical:
MediaQuery
.
of
(
context
).
size
.
height
*
0.008
,
horizontal:
MediaQuery
.
of
(
context
).
size
.
width
*
0.0004
,
vertical:
MediaQuery
.
of
(
context
).
size
.
height
*
0.008
,
horizontal:
MediaQuery
.
of
(
context
).
size
.
width
*
0.0004
,
),
decoration:
BoxDecoration
(
shape:
BoxShape
.
circle
,
color:
Colors
.
white
.
withOpacity
(
_current
==
entry
.
key
?
0.8
:
0.4
))),
color:
Colors
.
white
.
withOpacity
(
_current
==
entry
.
key
?
0.8
:
0.4
))),
);
}).
toList
(),
),
)
:
const
SizedBox
(
height:
0
),
]),
),
);
...
...
lib/ui/error.dart
0 → 100644
View file @
90dd4942
import
'package:flutter/material.dart'
;
import
'package:second_display/helper/config.dart'
;
import
'package:second_display/main.dart'
;
class
ErrorPage
extends
StatelessWidget
{
ErrorPage
({
Key
?
key
})
:
super
(
key:
key
);
final
String
?
baseUrls
=
prefs
.
getString
(
'base_url'
);
@override
Widget
build
(
BuildContext
context
)
{
return
Column
(
mainAxisAlignment:
MainAxisAlignment
.
center
,
children:
[
SizedBox
(
width:
MediaQuery
.
of
(
context
).
size
.
width
*
0.2
,
height:
MediaQuery
.
of
(
context
).
size
.
width
*
0.2
,
child:
const
Image
(
image:
AssetImage
(
"assets/images/error.png"
),
fit:
BoxFit
.
cover
,
)),
SizedBox
(
height:
MediaQuery
.
of
(
context
).
size
.
height
*
0.05
,
),
Text
(
"Error connect to server, Need to refresh and check the server"
,
style:
TextStyle
(
fontSize:
MediaQuery
.
of
(
context
).
size
.
height
*
0.03
,
fontWeight:
FontWeight
.
w500
,
color:
Colors
.
black
,
decoration:
TextDecoration
.
none
),
),
Row
(
mainAxisAlignment:
MainAxisAlignment
.
center
,
children:
[
Text
(
"Your Base Url: "
,
style:
TextStyle
(
fontSize:
MediaQuery
.
of
(
context
).
size
.
height
*
0.02
,
fontWeight:
FontWeight
.
w500
,
color:
Colors
.
black
,
decoration:
TextDecoration
.
none
),
),
Text
(
baseUrls
??
urlDefault
,
style:
TextStyle
(
fontSize:
MediaQuery
.
of
(
context
).
size
.
height
*
0.02
,
fontWeight:
FontWeight
.
w500
,
color:
Colors
.
red
,
decoration:
TextDecoration
.
none
),
),
],
),
SizedBox
(
height:
MediaQuery
.
of
(
context
).
size
.
height
*
0.05
,
),
Row
(
mainAxisAlignment:
MainAxisAlignment
.
center
,
children:
[
ElevatedButton
.
icon
(
onPressed:
()
{
Navigator
.
pushReplacementNamed
(
context
,
'/'
);
},
icon:
const
Icon
(
Icons
.
refresh_sharp
),
label:
const
Text
(
"Refresh"
)),
SizedBox
(
width:
MediaQuery
.
of
(
context
).
size
.
width
*
0.01
,
),
ElevatedButton
.
icon
(
onPressed:
()
{
Navigator
.
pushReplacementNamed
(
context
,
'/inputbase'
);
},
icon:
const
Icon
(
Icons
.
input_outlined
),
label:
const
Text
(
"Input base Url"
))
],
)
],
);
}
}
lib/ui/input_base_url.dart
0 → 100644
View file @
90dd4942
import
'package:flutter/material.dart'
;
import
'package:second_display/helper/config.dart'
;
import
'package:second_display/main.dart'
;
import
'package:second_display/ui/error.dart'
;
class
InputBaseUrl
extends
StatefulWidget
{
const
InputBaseUrl
({
Key
?
key
})
:
super
(
key:
key
);
@override
State
<
InputBaseUrl
>
createState
()
=>
_InputBaseUrlState
();
}
class
_InputBaseUrlState
extends
State
<
InputBaseUrl
>
{
final
_baseUrlController
=
TextEditingController
();
late
String
urlBase
;
@override
void
initState
()
{
final
String
?
_baseUrls
=
prefs
.
getString
(
'baseUrl'
);
urlBase
=
_baseUrls
??
urlDefault
;
_baseUrlController
.
text
=
urlBase
;
super
.
initState
();
}
@override
Widget
build
(
BuildContext
context
)
{
return
Scaffold
(
body:
Center
(
child:
Container
(
height:
MediaQuery
.
of
(
context
).
size
.
height
*
0.5
,
width:
MediaQuery
.
of
(
context
).
size
.
width
*
0.5
,
// color: Colors.red,
child:
Column
(
children:
[
TextField
(
controller:
_baseUrlController
,
style:
const
TextStyle
(
color:
Colors
.
black
),
decoration:
InputDecoration
(
// border: InputBorder.none,
prefixIcon:
const
Icon
(
Icons
.
attach_money_rounded
,
color:
Colors
.
white30
,
),
hintText:
urlBase
,
hintStyle:
TextStyle
(
color:
Colors
.
black
.
withOpacity
(
0.8
)),
),
),
const
SizedBox
(
height:
30
,
),
ElevatedButton
.
icon
(
onPressed:
()
async
{
await
prefs
.
setString
(
'base_url'
,
_baseUrlController
.
text
);
final
String
?
baseUrls
=
prefs
.
getString
(
'base_url'
);
Navigator
.
pushReplacement
(
context
,
MaterialPageRoute
(
builder:
(
context
)
=>
ErrorPage
()));
},
icon:
const
Icon
(
Icons
.
check
),
label:
const
Text
(
"Input base Url"
))
],
),
),
),
);
}
}
lib/ui/main_page.dart
View file @
90dd4942
...
...
@@ -3,6 +3,7 @@ import 'package:flutter_bloc/flutter_bloc.dart';
import
'package:second_display/bloc/config_display_blog.dart'
;
import
'package:second_display/bloc/order_detail.dart'
;
import
'package:second_display/bloc/orders_bloc.dart'
;
import
'package:second_display/main.dart'
;
import
'package:second_display/models/config_display.dart'
;
import
'package:second_display/ui/carousel.dart'
;
import
'package:second_display/ui/orders.dart'
;
...
...
@@ -16,12 +17,18 @@ class MainPage extends StatelessWidget {
Widget
build
(
BuildContext
context
)
{
context
.
read
<
OrdersBloc
>().
getOrderList
();
context
.
read
<
OrderDetailBloc
>().
getOrderDetailList
();
return
MaterialApp
(
return
SafeArea
(
child:
MaterialApp
(
debugShowCheckedModeBanner:
false
,
home:
Scaffold
(
body:
BlocBuilder
<
ConfigDisplayBloc
,
List
<
ConfigDisplay
>>(
home:
Scaffold
(
body:
BlocBuilder
<
ConfigDisplayBloc
,
List
<
ConfigDisplay
>>(
builder:
(
context
,
configState
)
{
int
valueIntBackgroundColorCarouselVideo
=
int
.
parse
(
configState
[
0
].
backgroundColorCarouselVideo
,
radix:
16
);
if
(
configState
.
isEmpty
)
{
navigatorKey
.
currentState
?.
pushNamed
(
'/error'
);
}
int
valueIntBackgroundColorCarouselVideo
=
int
.
parse
(
configState
[
0
].
backgroundColorCarouselVideo
,
radix:
16
);
final
Color
colorBackgroundCarouselandVideo
=
Color
(
valueIntBackgroundColorCarouselVideo
);
...
...
@@ -34,6 +41,12 @@ class MainPage extends StatelessWidget {
final
Color
backgroundColorOrder
=
Color
(
valueIntBackgroundColorOrder
);
List
<
String
>
images
=
[];
var
imageString
=
configState
[
0
].
images
.
split
(
';'
);
for
(
int
i
=
0
;
i
<
imageString
.
length
;
i
++)
{
images
.
add
(
imageString
[
i
].
trim
());
}
prefs
.
setStringList
(
"imageList"
,
images
);
return
Row
(
children:
[
(
configState
[
0
].
mediaType
==
'video'
)
...
...
@@ -42,19 +55,24 @@ class MainPage extends StatelessWidget {
width:
MediaQuery
.
of
(
context
).
size
.
width
*
0.6
,
color:
colorBackgroundCarouselandVideo
,
// color: Colors.white,
child:
VideoPromotion
(),
child:
VideoPromotion
(
videoUrl:
configState
[
0
].
videoPromotionUrl
),
)
:
(
configState
[
0
].
mediaType
==
'image'
)
?
Container
(
height:
MediaQuery
.
of
(
context
).
size
.
height
,
width:
MediaQuery
.
of
(
context
).
size
.
width
*
0.6
,
child:
CarouselIndicator
(
backgroundColor:
colorBackgroundCarouselandVideo
),
backgroundColor:
colorBackgroundCarouselandVideo
),
)
:
Container
(
height:
MediaQuery
.
of
(
context
).
size
.
height
,
width:
MediaQuery
.
of
(
context
).
size
.
width
*
0.6
,
child:
YoutubeVideo
(),
child:
YoutubeVideo
(
backgroundColor:
colorBackgroundCarouselandVideo
,
youtubeId:
configState
[
0
].
youtubeId
),
),
Container
(
height:
MediaQuery
.
of
(
context
).
size
.
height
,
...
...
@@ -66,6 +84,7 @@ class MainPage extends StatelessWidget {
);
},
)),
),
);
}
}
lib/ui/orders.dart
View file @
90dd4942
...
...
@@ -45,7 +45,7 @@ class OrderPage extends StatelessWidget {
children:
[
Container
(
// color: Colors.red,
height:
MediaQuery
.
of
(
context
).
size
.
height
*
0.
1
,
height:
MediaQuery
.
of
(
context
).
size
.
height
*
0.
08
,
child:
Row
(
mainAxisAlignment:
MainAxisAlignment
.
center
,
children:
[
...
...
@@ -53,7 +53,7 @@ class OrderPage extends StatelessWidget {
mainAxisAlignment:
MainAxisAlignment
.
center
,
children:
[
Text
(
"Kasir"
,
list
.
order_user_name
,
style:
TextStyle
(
fontSize:
MediaQuery
.
of
(
context
).
size
.
height
*
0.04
,
...
...
@@ -95,7 +95,7 @@ class OrderPage extends StatelessWidget {
itemCount:
detailOrder
.
length
,
itemBuilder:
(
context
,
i
)
{
var
optionStr
=
detailOrder
[
i
].
optionOrder
;
var
O
rderOptionDetail
=
optionStr
.
split
(
';'
);
var
o
rderOptionDetail
=
optionStr
.
split
(
';'
);
var
amountEachOrder
=
double
.
tryParse
(
detailOrder
[
i
].
total
)
??
0
;
var
amountEachOrderText
=
...
...
@@ -138,7 +138,7 @@ class OrderPage extends StatelessWidget {
),
),
for
(
int
i
=
0
;
i
<
O
rderOptionDetail
.
length
;
i
<
o
rderOptionDetail
.
length
;
i
++)
Container
(
// color: Colors.green,
...
...
@@ -159,7 +159,7 @@ class OrderPage extends StatelessWidget {
listOforderOption
(
context
,
Alignment
.
topLeft
,
O
rderOptionDetail
[
i
].
trim
()),
o
rderOptionDetail
[
i
].
trim
()),
listOforderOption
(
context
,
Alignment
.
centerRight
,
''
)
],
...
...
lib/ui/splash.dart
View file @
90dd4942
import
'dart:html'
;
import
'package:flutter/material.dart'
;
import
'package:flutter_bloc/flutter_bloc.dart'
;
import
'package:loading_animations/loading_animations.dart'
;
import
'package:second_display/api/api.dart'
;
import
'package:second_display/bloc/config_display_blog.dart'
;
import
'package:second_display/helper/config.dart'
;
import
'package:second_display/main.dart'
;
import
'package:second_display/models/config_display.dart'
;
import
'package:second_display/ui/main_page.dart'
;
class
Splash
extends
StatefulWidget
{
...
...
@@ -11,32 +17,45 @@ class Splash extends StatefulWidget {
State
<
Splash
>
createState
()
=>
_SplashState
();
}
class
_SplashState
extends
State
<
Splash
>
{
// bool isLoaded = false;
// Future<List<ConfigApl>> config({url = ""}) async {
// // String? base_urlapi = prefs.getString('base_url');
// List<ConfigApl> apiConfigs = [];
// try {
// var apiConfig = await Api.getConfig(url: url);
// apiConfigs = apiConfig;
// return apiConfigs;
// } catch (e) {
// return apiConfigs;
// }
// }
Future
<
List
<
ConfigDisplay
>>
config
(
String
url
)
async
{
List
<
ConfigDisplay
>
apiConfigs
=
[];
try
{
var
apiConfig
=
await
Api
.
getConfigDisplay
(
url:
url
);
apiConfigs
=
apiConfig
;
return
apiConfigs
;
}
catch
(
e
)
{
return
apiConfigs
;
}
}
class
_SplashState
extends
State
<
Splash
>
{
@override
void
initState
()
{
Future
.
delayed
(
const
Duration
(
seconds:
2
),
()
{
String
?
base_urlapi
=
prefs
.
getString
(
'base_url'
);
config
(
base_urlapi
??
urlDefault
).
then
((
value
)
async
{
context
.
read
<
ConfigDisplayBloc
>()
.
getConfigDisplay
(
base_urlapi
??
urlDefault
);
await
prefs
.
setString
(
'background_color_carousel_video'
,
value
[
0
].
backgroundColorCarouselVideo
);
await
prefs
.
setString
(
'text_color'
,
value
[
0
].
textColor
);
await
prefs
.
setString
(
'backgroundColorOrder'
,
value
[
0
].
backgroundColorOrder
);
await
prefs
.
setString
(
'mediaType'
,
value
[
0
].
mediaType
);
await
prefs
.
setString
(
'youtubeId'
,
value
[
0
].
youtubeId
);
await
prefs
.
setString
(
'videoPromotionUrl'
,
value
[
0
].
videoPromotionUrl
);
await
prefs
.
setString
(
'images'
,
value
[
0
].
images
);
Future
.
delayed
(
const
Duration
(
seconds:
3
),
()
{
Navigator
.
push
(
context
,
MaterialPageRoute
(
builder:
(
_
)
=>
MainPage
()));
});
});
super
.
initState
();
}
@override
Widget
build
(
BuildContext
context
)
{
context
.
read
<
ConfigDisplayBloc
>().
getConfigDisplay
();
return
Column
(
mainAxisAlignment:
MainAxisAlignment
.
center
,
children:
[
...
...
lib/ui/video_promotion.dart
View file @
90dd4942
...
...
@@ -3,7 +3,8 @@ import 'package:loading_animations/loading_animations.dart';
import
'package:video_player/video_player.dart'
;
class
VideoPromotion
extends
StatefulWidget
{
const
VideoPromotion
({
Key
?
key
})
:
super
(
key:
key
);
final
String
videoUrl
;
const
VideoPromotion
({
Key
?
key
,
required
this
.
videoUrl
})
:
super
(
key:
key
);
@override
State
<
VideoPromotion
>
createState
()
=>
_VideoPromotionState
();
...
...
@@ -13,8 +14,7 @@ class _VideoPromotionState extends State<VideoPromotion> {
VideoPlayerController
?
_controller
;
@override
void
initState
()
{
_controller
=
VideoPlayerController
.
network
(
'https://media.istockphoto.com/videos/man-in-formal-suit-dancing-and-throwing-money-video-id892877794'
)
_controller
=
VideoPlayerController
.
network
(
widget
.
videoUrl
)
..
setLooping
(
true
)
..
initialize
().
then
((
_
)
{
// Ensure the first frame is shown after the video is initialized, even before the play button has been pressed.
...
...
lib/ui/youtube.dart
View file @
90dd4942
import
'package:flutter/material.dart'
;
import
'package:flutter_html/flutter_html.dart'
;
import
'package:flutter/services.dart'
;
// import 'package:flutter_html/flutter_html.dart';
import
'package:youtube_player_iframe/youtube_player_iframe.dart'
;
class
YoutubeVideo
extends
StatefulWidget
{
const
YoutubeVideo
({
Key
?
key
})
:
super
(
key:
key
);
final
String
youtubeId
;
final
Color
backgroundColor
;
const
YoutubeVideo
(
{
Key
?
key
,
required
this
.
youtubeId
,
required
this
.
backgroundColor
})
:
super
(
key:
key
);
@override
State
<
YoutubeVideo
>
createState
()
=>
_YoutubeVideoState
();
}
class
_YoutubeVideoState
extends
State
<
YoutubeVideo
>
{
late
YoutubePlayerController
_controller
;
@override
void
initState
()
{
super
.
initState
();
_controller
=
YoutubePlayerController
(
initialVideoId:
widget
.
youtubeId
,
params:
YoutubePlayerParams
(
playlist:
[
widget
.
youtubeId
,
],
loop:
true
,
mute:
true
,
enableCaption:
false
,
startAt:
const
Duration
(
minutes:
0
,
seconds:
0
),
showControls:
false
,
showFullscreenButton:
false
,
desktopMode:
true
,
privacyEnhanced:
true
,
useHybridComposition:
true
,
),
);
_controller
.
onEnterFullscreen
=
()
{
SystemChrome
.
setPreferredOrientations
([
DeviceOrientation
.
landscapeLeft
,
DeviceOrientation
.
landscapeRight
,
]);
};
_controller
.
onExitFullscreen
=
()
{};
}
@override
Widget
build
(
BuildContext
context
)
{
var
widthYoutbe
=
MediaQuery
.
of
(
context
).
size
.
width
*
0.6
;
var
heighYoutbe
=
MediaQuery
.
of
(
context
).
size
.
height
;
return
Center
(
// return Center(
// child: Container(
// color: widget.backgroundColor,
// child: Html(
// data:
// '<iframe width="$widthYoutbe" height="$heighYoutbe" src="https://www.youtube.com/embed/${widget.youtubeId}?rel=0&autoplay=1&mute=1&enablejsapi=1&controls=0&loop=1&playlist=${widget.youtubeId}&autohide=1&modestbranding=1" frameborder="0" clipboard-write; encrypted-media; gyroscope; picture-in-picture" allowfullscreen></iframe>',
// ),
// ),
// );
return
YoutubePlayerControllerProvider
(
controller:
_controller
,
child:
Container
(
// color: Colors.green,
child:
Html
(
data:
'<iframe width="
$widthYoutbe
" height="
$heighYoutbe
" src="https://www.youtube.com/embed/Mi72fOuiwA0?rel=0&modestbranding=1&autoplay=1&mute=1&enablejsapi=1&controls=0&loop=1&autohide=1" frameborder="0" clipboard-write; encrypted-media; gyroscope; picture-in-picture" allowfullscreen></iframe>'
,
)),
);
width:
widthYoutbe
,
height:
heighYoutbe
,
child:
YoutubePlayerControllerProvider
(
// Provides controller to all the widget below it.
controller:
_controller
,
child:
const
YoutubePlayerIFrame
(
aspectRatio:
16
/
9
,
),
),
));
}
}
pubspec.lock
View file @
90dd4942
...
...
@@ -99,6 +99,13 @@ packages:
url: "https://pub.dartlang.org"
source: hosted
version: "1.1.2"
file:
dependency: transitive
description:
name: file
url: "https://pub.dartlang.org"
source: hosted
version: "6.1.2"
flutter:
dependency: "direct main"
description: flutter
...
...
@@ -118,6 +125,13 @@ packages:
url: "https://pub.dartlang.org"
source: hosted
version: "2.2.1"
flutter_inappwebview:
dependency: transitive
description:
name: flutter_inappwebview
url: "https://pub.dartlang.org"
source: hosted
version: "5.3.2"
flutter_layout_grid:
dependency: transitive
description:
...
...
@@ -261,6 +275,27 @@ packages:
url: "https://pub.dartlang.org"
source: hosted
version: "0.2.1"
path_provider_linux:
dependency: transitive
description:
name: path_provider_linux
url: "https://pub.dartlang.org"
source: hosted
version: "2.1.5"
path_provider_platform_interface:
dependency: transitive
description:
name: path_provider_platform_interface
url: "https://pub.dartlang.org"
source: hosted
version: "2.0.3"
path_provider_windows:
dependency: transitive
description:
name: path_provider_windows
url: "https://pub.dartlang.org"
source: hosted
version: "2.0.5"
petitparser:
dependency: transitive
description:
...
...
@@ -268,6 +303,13 @@ packages:
url: "https://pub.dartlang.org"
source: hosted
version: "4.4.0"
platform:
dependency: transitive
description:
name: platform
url: "https://pub.dartlang.org"
source: hosted
version: "3.1.0"
plugin_platform_interface:
dependency: transitive
description:
...
...
@@ -275,6 +317,13 @@ packages:
url: "https://pub.dartlang.org"
source: hosted
version: "2.1.2"
process:
dependency: transitive
description:
name: process
url: "https://pub.dartlang.org"
source: hosted
version: "4.2.4"
provider:
dependency: transitive
description:
...
...
@@ -289,6 +338,62 @@ packages:
url: "https://pub.dartlang.org"
source: hosted
version: "3.0.1+1"
shared_preferences:
dependency: "direct main"
description:
name: shared_preferences
url: "https://pub.dartlang.org"
source: hosted
version: "2.0.13"
shared_preferences_android:
dependency: transitive
description:
name: shared_preferences_android
url: "https://pub.dartlang.org"
source: hosted
version: "2.0.11"
shared_preferences_ios:
dependency: transitive
description:
name: shared_preferences_ios
url: "https://pub.dartlang.org"
source: hosted
version: "2.1.0"
shared_preferences_linux:
dependency: transitive
description:
name: shared_preferences_linux
url: "https://pub.dartlang.org"
source: hosted
version: "2.1.0"
shared_preferences_macos:
dependency: transitive
description:
name: shared_preferences_macos
url: "https://pub.dartlang.org"
source: hosted
version: "2.0.3"
shared_preferences_platform_interface:
dependency: transitive
description:
name: shared_preferences_platform_interface
url: "https://pub.dartlang.org"
source: hosted
version: "2.0.0"
shared_preferences_web:
dependency: transitive
description:
name: shared_preferences_web
url: "https://pub.dartlang.org"
source: hosted
version: "2.0.3"
shared_preferences_windows:
dependency: transitive
description:
name: shared_preferences_windows
url: "https://pub.dartlang.org"
source: hosted
version: "2.1.0"
sky_engine:
dependency: transitive
description: flutter
...
...
@@ -350,6 +455,62 @@ packages:
url: "https://pub.dartlang.org"
source: hosted
version: "1.3.0"
url_launcher:
dependency: transitive
description:
name: url_launcher
url: "https://pub.dartlang.org"
source: hosted
version: "6.0.20"
url_launcher_android:
dependency: transitive
description:
name: url_launcher_android
url: "https://pub.dartlang.org"
source: hosted
version: "6.0.15"
url_launcher_ios:
dependency: transitive
description:
name: url_launcher_ios
url: "https://pub.dartlang.org"
source: hosted
version: "6.0.15"
url_launcher_linux:
dependency: transitive
description:
name: url_launcher_linux
url: "https://pub.dartlang.org"
source: hosted
version: "3.0.0"
url_launcher_macos:
dependency: transitive
description:
name: url_launcher_macos
url: "https://pub.dartlang.org"
source: hosted
version: "3.0.0"
url_launcher_platform_interface:
dependency: transitive
description:
name: url_launcher_platform_interface
url: "https://pub.dartlang.org"
source: hosted
version: "2.0.5"
url_launcher_web:
dependency: transitive
description:
name: url_launcher_web
url: "https://pub.dartlang.org"
source: hosted
version: "2.0.9"
url_launcher_windows:
dependency: transitive
description:
name: url_launcher_windows
url: "https://pub.dartlang.org"
source: hosted
version: "3.0.0"
url_strategy:
dependency: "direct main"
description:
...
...
@@ -476,6 +637,13 @@ packages:
url: "https://pub.dartlang.org"
source: hosted
version: "2.4.1"
xdg_directories:
dependency: transitive
description:
name: xdg_directories
url: "https://pub.dartlang.org"
source: hosted
version: "0.2.0+1"
xml:
dependency: transitive
description:
...
...
@@ -483,6 +651,13 @@ packages:
url: "https://pub.dartlang.org"
source: hosted
version: "5.3.1"
youtube_player_iframe:
dependency: "direct main"
description:
name: youtube_player_iframe
url: "https://pub.dartlang.org"
source: hosted
version: "2.2.2"
sdks:
dart: ">=2.16.1 <3.0.0"
flutter: ">=2.
8
.0"
flutter: ">=2.
10
.0"
pubspec.yaml
View file @
90dd4942
...
...
@@ -36,8 +36,10 @@ dependencies:
http
:
^0.13.4
intl
:
^0.17.0
loading_animations
:
^2.2.0
shared_preferences
:
^2.0.13
url_strategy
:
^0.2.0
video_player
:
^2.3.0
youtube_player_iframe
:
^2.2.2
dev_dependencies
:
flutter_lints
:
^1.0.0
...
...
@@ -56,6 +58,7 @@ flutter:
# To add assets to your application, add an assets section, like this:
assets
:
-
assets/file.json
-
assets/images/
# - images/a_dot_ham.jpeg
# An image asset can refer to one or more resolution-specific "variants", see
# https://flutter.dev/assets-and-images/#resolution-aware.
...
...
windows/flutter/generated_plugin_registrant.cc
View file @
90dd4942
...
...
@@ -6,6 +6,9 @@
#include "generated_plugin_registrant.h"
#include <url_launcher_windows/url_launcher_windows.h>
void
RegisterPlugins
(
flutter
::
PluginRegistry
*
registry
)
{
UrlLauncherWindowsRegisterWithRegistrar
(
registry
->
GetRegistrarForPlugin
(
"UrlLauncherWindows"
));
}
windows/flutter/generated_plugins.cmake
View file @
90dd4942
...
...
@@ -3,6 +3,7 @@
#
list
(
APPEND FLUTTER_PLUGIN_LIST
url_launcher_windows
)
set
(
PLUGIN_BUNDLED_LIBRARIES
)
...
...
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