Browse Source

show current user when add actions

master
daivph 5 years ago
parent
commit
cf62146d87
4 changed files with 37 additions and 0 deletions
  1. +1
    -0
      lib/data/repository/authentication_repository.dart
  2. +23
    -0
      lib/presentation/screens/actions/nursery/sc_edit_action_nursery.dart
  3. +12
    -0
      lib/presentation/screens/plot/sc_plot.dart
  4. +1
    -0
      lib/utils/pref.dart

+ 1
- 0
lib/data/repository/authentication_repository.dart View File

@@ -43,6 +43,7 @@ class AuthenticationRepository {
void logOut() {
pref.saveString(DATA_CONST.TOKEN_KEY, "");
pref.saveString(DATA_CONST.PUSH_KEY, "");
pref.saveString(DATA_CONST.CURRENT_FULL_NAME, "");
_controller.add(AuthenticationStatus.unauthenticated);
}


+ 23
- 0
lib/presentation/screens/actions/nursery/sc_edit_action_nursery.dart View File

@@ -57,6 +57,7 @@ class _EditActionNurseryState extends State<EditActionNurseryScreen> {
TextEditingController _descriptionController = TextEditingController();
TextEditingController _workerNameController = TextEditingController();
TextEditingController _trayNumberController = TextEditingController();
final _executeByController = TextEditingController();
String executeTimeView;
DateTime executeTime = DateTime.now();
List<NurseryDetail> currentNurseryDetail = List<NurseryDetail>();
@@ -67,9 +68,15 @@ class _EditActionNurseryState extends State<EditActionNurseryScreen> {
List<String> filePaths = List<String>();
var changeFileController = Get.put(ChangeFileController());

Future<Null> getSharedPrefs() async {
var currentFullName = await pref.getString(DATA_CONST.CURRENT_FULL_NAME);
_executeByController.text = currentFullName ?? "";
}

@override
void initState() {
super.initState();
getSharedPrefs();
changeSupply.initValue();
changeFileController.initValue();
_nursery.nurseryDetail = new List<NurseryDetail>();
@@ -288,6 +295,16 @@ class _EditActionNurseryState extends State<EditActionNurseryScreen> {
);
}

Widget _executeByField() {
return TextFormField(
keyboardType: TextInputType.text,
decoration: InputDecoration(labelText: "Người thực hiện"),
enabled: false,
controller: _executeByController,
onSaved: (newValue) {},
);
}

Widget _btnAddWorker() {
//TODO :check flow error sua item -> xoa list -> bam nut them
return Builder(builder: (context) {
@@ -556,6 +573,8 @@ class _EditActionNurseryState extends State<EditActionNurseryScreen> {
.formatNumtoStringDecimal();
_descriptionController.text =
_nursery.description;
_executeByController.text =
_nursery.executeBy;
try {
executeTime =
DateFormat("yyyy-MM-dd'T'HH:mm:ss'Z'")
@@ -639,6 +658,10 @@ class _EditActionNurseryState extends State<EditActionNurseryScreen> {
SizedBox(
height: 8.0,
),
_executeByField(),
SizedBox(
height: 8.0,
),
_btnAddWorker(),
SizedBox(
height: 8.0,

+ 12
- 0
lib/presentation/screens/plot/sc_plot.dart View File

@@ -33,10 +33,12 @@ class _PlotListScreenState extends State<PlotListScreen> {
var token;
var client;
String pushkey = "";
String currentFullName = "";

Future<Null> getSharedPrefs() async {
token = await pref.getString(DATA_CONST.TOKEN_KEY);
pushkey = await pref.getString(DATA_CONST.PUSH_KEY);
currentFullName = await pref.getString(DATA_CONST.CURRENT_FULL_NAME);
var options = BaseOptions(baseUrl: ConstCommon.baseUrl);
options.headers["Authorization"] = "Bearer $token";
client = Dio(options);
@@ -76,6 +78,16 @@ class _PlotListScreenState extends State<PlotListScreen> {
} else {
print("Don't need get push key");
}

if (currentFullName?.isEmpty ?? true) {
try {
var currentUser = await _userRepository.getUser();
pref.saveString(DATA_CONST.CURRENT_FULL_NAME, currentUser.fullName);
print("fullname: ${currentUser.fullName}");
} catch (e) {
print("error: ${e.toString()}");
}
}
}

@override

+ 1
- 0
lib/utils/pref.dart View File

@@ -41,4 +41,5 @@ class DATA_CONST {
static const String SHRIMP_LITER = "SHRIMP_LITER";
static const String SHRIMP_POND_ID = "SHRIMP_POND_ID";
static const String PUSH_KEY = "PUSH_KEY";
static const String CURRENT_FULL_NAME = "CURRENT_FULL_NAME";
}

Loading…
Cancel
Save