67 lines
2.3 KiB
Dart
67 lines
2.3 KiB
Dart
import 'package:baseproject/core/common/index.dart';
|
|
import 'package:baseproject/core/components/constants_widget.dart';
|
|
import 'package:baseproject/core/language/app_localizations.dart';
|
|
import 'package:baseproject/features/model/index.dart';
|
|
import 'package:baseproject/features/presentation/app/bloc/user_bloc.dart';
|
|
import 'package:baseproject/features/route/route_goto.dart';
|
|
import 'package:flutter/material.dart';
|
|
|
|
class Home extends StatefulWidget {
|
|
const Home({Key? key}) : super(key: key);
|
|
|
|
@override
|
|
State<Home> createState() => _HomeState();
|
|
}
|
|
|
|
class _HomeState extends State<Home> {
|
|
@override
|
|
Widget build(BuildContext context) {
|
|
return Scaffold(
|
|
body: Center(
|
|
child: BlocBuilder<UserBloc, BaseStateBloc<UserInfoDto?>>(
|
|
builder: (context, state) {
|
|
final userInfo = state.model;
|
|
if (userInfo != null) {
|
|
return Column(
|
|
mainAxisAlignment: MainAxisAlignment.center,
|
|
crossAxisAlignment: CrossAxisAlignment.center,
|
|
children: [
|
|
Text("Chào ${userInfo.fullName ?? ''}"),
|
|
ConstantWidget.heightSpace16,
|
|
ConstantWidget.buildPrimaryButton(
|
|
onPressed: () {
|
|
gotoMyOrders(context);
|
|
},
|
|
text: 'Khóa học đã mua',
|
|
),
|
|
ConstantWidget.heightSpace16,
|
|
ConstantWidget.buildPrimaryButton(
|
|
onPressed: () {
|
|
BlocProvider.of<UserBloc>(context).logout();
|
|
},
|
|
text: 'Đăng xuất',
|
|
),
|
|
],
|
|
);
|
|
} else {
|
|
return Column(
|
|
mainAxisAlignment: MainAxisAlignment.center,
|
|
crossAxisAlignment: CrossAxisAlignment.center,
|
|
children: [
|
|
Text(AppLocalizations.of(context)!.translate("first_string")),
|
|
ConstantWidget.buildPrimaryButton(
|
|
onPressed: () {
|
|
gotoLogin(context);
|
|
},
|
|
text: 'Đăng nhập',
|
|
),
|
|
],
|
|
);
|
|
}
|
|
},
|
|
),
|
|
),
|
|
);
|
|
}
|
|
}
|