Commit 4787dbd4 authored by Dio Maulana's avatar Dio Maulana

menambahkan double back ketika exit

parent 8a93e9ea
......@@ -7,22 +7,44 @@ 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';
import 'package:second_display/ui/settings/menu_setting.dart';
import 'package:second_display/ui/video_promotion.dart';
import 'package:second_display/ui/youtube.dart';
import 'package:double_back_to_close/double_back_to_close.dart';
// ignore: must_be_immutable
class MainPage extends StatelessWidget {
bool isOrderActive = true;
MainPage({Key? key}) : super(key: key);
class MainPage extends StatefulWidget {
const MainPage({Key? key}) : super(key: key);
@override
State<MainPage> createState() => _MainPageState();
}
class _MainPageState extends State<MainPage> {
final bool isOrderActive = prefs.getBool('isOrderActive') ?? true;
final bool isAdActive = prefs.getBool('isAdActive') ?? true;
bool allowClose = false;
@override
Widget build(BuildContext context) {
context.read<OrdersBloc>().getOrderList();
context.read<OrderDetailBloc>().getOrderDetailList();
return SafeArea(
return DoubleBack(
message: "Press back again to close",
condition: allowClose,
onConditionFail: () {
setState(() {
allowClose = true;
});
},
waitForSecondBackPress: 3,
child: SafeArea(
child: MaterialApp(
debugShowCheckedModeBanner: false,
home:
Scaffold(body: BlocBuilder<ConfigDisplayBloc, List<ConfigDisplay>>(
home: Scaffold(
body: BlocBuilder<ConfigDisplayBloc, List<ConfigDisplay>>(
builder: (context, configState) {
if (configState.isEmpty) {
navigatorKey.currentState?.pushNamed('/error');
......@@ -48,9 +70,12 @@ class MainPage extends StatelessWidget {
images.add(imageString[i].trim());
}
prefs.setStringList("imageList", images);
return Row(
return Stack(
children: [
(configState[0].mediaType == 'video')
Row(
children: [
(isAdActive)
? (configState[0].mediaType == 'video')
? Container(
height: MediaQuery.of(context).size.height,
width: (isOrderActive)
......@@ -59,33 +84,43 @@ class MainPage extends StatelessWidget {
color: colorBackgroundCarouselandVideo,
// color: Colors.white,
child: VideoPromotion(
videoUrl: configState[0].videoPromotionUrl),
videoUrl:
configState[0].videoPromotionUrl),
)
: (configState[0].mediaType == 'image')
? Container(
height: MediaQuery.of(context).size.height,
? SizedBox(
height:
MediaQuery.of(context).size.height,
width: (isOrderActive)
? MediaQuery.of(context).size.width * 0.6
: MediaQuery.of(context).size.width * 1,
? MediaQuery.of(context).size.width *
0.6
: MediaQuery.of(context).size.width *
1,
child: CarouselIndicator(
backgroundColor:
colorBackgroundCarouselandVideo),
)
: Container(
height: MediaQuery.of(context).size.height,
: SizedBox(
height:
MediaQuery.of(context).size.height,
width: (isOrderActive)
? MediaQuery.of(context).size.width * 0.6
: MediaQuery.of(context).size.width * 1,
? MediaQuery.of(context).size.width *
0.6
: MediaQuery.of(context).size.width *
1,
child: YoutubeVideo(
backgroundColor:
colorBackgroundCarouselandVideo,
youtubeId: configState[0].youtubeId,
isOrderActive: isOrderActive),
),
)
: const SizedBox(height: 0, width: 0),
(isOrderActive)
? Container(
height: MediaQuery.of(context).size.height,
width: MediaQuery.of(context).size.width * 0.4,
width: (isAdActive)
? MediaQuery.of(context).size.width * 0.4
: MediaQuery.of(context).size.width * 1,
color: backgroundColorOrder,
// decoration: const BoxDecoration(
// gradient: LinearGradient(
......@@ -100,10 +135,38 @@ class MainPage extends StatelessWidget {
)
: const SizedBox(height: 0, width: 0)
],
),
Row(
mainAxisAlignment: MainAxisAlignment.end,
children: [
Container(
margin: EdgeInsets.only(
top: MediaQuery.of(context).size.height * 0.01,
left: MediaQuery.of(context).size.height * 0.01),
child: GestureDetector(
onTap: () {
Navigator.push(
context,
MaterialPageRoute(
builder: (BuildContext context) =>
const SettingsMenu(),
),
);
},
child: Icon(
Icons.settings,
color: textColor,
),
),
),
],
)
],
);
},
)),
),
),
);
}
}
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment