Commit 5e7c677a authored by Lucas NAURY's avatar Lucas NAURY

Visuel de la page de création d'annonce

parent 7df0974e
package com.example.tpleboncoin.ui.ajout_annonce; package com.example.tpleboncoin.ui.ajout_annonce;
import android.content.Intent;
import android.os.Bundle; import android.os.Bundle;
import android.view.LayoutInflater; import android.view.LayoutInflater;
import android.view.View; import android.view.View;
import android.view.ViewGroup; import android.view.ViewGroup;
import android.widget.Button;
import android.widget.EditText;
import android.widget.TextView; import android.widget.TextView;
import androidx.annotation.NonNull; import androidx.annotation.NonNull;
import androidx.fragment.app.Fragment; import androidx.fragment.app.Fragment;
import androidx.lifecycle.ViewModelProvider; import androidx.lifecycle.ViewModelProvider;
import androidx.navigation.Navigation;
import com.example.tpleboncoin.R;
import com.example.tpleboncoin.databinding.FragmentAjoutAnnonceBinding; import com.example.tpleboncoin.databinding.FragmentAjoutAnnonceBinding;
import com.example.tpleboncoin.ui.home.HomeFragment;
import com.google.android.material.snackbar.Snackbar;
public class AjoutAnnonceFragment extends Fragment { public class AjoutAnnonceFragment extends Fragment {
...@@ -24,8 +31,31 @@ public class AjoutAnnonceFragment extends Fragment { ...@@ -24,8 +31,31 @@ public class AjoutAnnonceFragment extends Fragment {
binding = FragmentAjoutAnnonceBinding.inflate(inflater, container, false); binding = FragmentAjoutAnnonceBinding.inflate(inflater, container, false);
View root = binding.getRoot(); View root = binding.getRoot();
final TextView textView = binding.textAjoutAnnonce;
ajout_annonceViewModel.getText().observe(getViewLifecycleOwner(), textView::setText); final EditText titreAnnonce = binding.titreAnnonce;
final EditText adresseAnnonce = binding.adresseAnnonce;
final EditText prixAnnonce = binding.prixAnnonce;
final Button boutonCreation = binding.boutonAjoutAnnonce;
boutonCreation.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View view) {
// On vérifie si les informations sont correctement remplies
if(titreAnnonce.getText().toString().equals("") || adresseAnnonce.getText().toString().equals("") || prixAnnonce.getText().toString().equals("")){
Snackbar.make(view, "Veuillez remplir les champs pour créer l'annonce", Snackbar.LENGTH_LONG).show();
return;
}
Navigation.findNavController(view).navigate(R.id.navigation_home);
//Intent voirNouvelleListe = new Intent(HomeFragment.this, Accelerometre.class);
//startActivity(voirAccel);
}
});
return root; return root;
} }
......
...@@ -5,15 +5,4 @@ import androidx.lifecycle.MutableLiveData; ...@@ -5,15 +5,4 @@ import androidx.lifecycle.MutableLiveData;
import androidx.lifecycle.ViewModel; import androidx.lifecycle.ViewModel;
public class AjoutAnnonceViewModel extends ViewModel { public class AjoutAnnonceViewModel extends ViewModel {
private final MutableLiveData<String> mText;
public AjoutAnnonceViewModel() {
mText = new MutableLiveData<>();
mText.setValue("Ajouter une annonce");
}
public LiveData<String> getText() {
return mText;
}
} }
\ No newline at end of file
...@@ -6,17 +6,111 @@ ...@@ -6,17 +6,111 @@
android:layout_height="match_parent" android:layout_height="match_parent"
tools:context=".ui.ajout_annonce.AjoutAnnonceFragment"> tools:context=".ui.ajout_annonce.AjoutAnnonceFragment">
<TextView <LinearLayout
android:id="@+id/text_ajout_annonce"
android:layout_width="match_parent" android:layout_width="match_parent"
android:layout_height="wrap_content" android:layout_height="match_parent"
android:layout_marginStart="8dp" android:orientation="vertical"
android:layout_marginTop="8dp" android:padding="@dimen/activity_horizontal_margin">
android:layout_marginEnd="8dp"
android:textAlignment="center" <TextView
android:textSize="20sp" android:id="@+id/titre"
app:layout_constraintBottom_toBottomOf="parent" android:layout_width="match_parent"
app:layout_constraintEnd_toEndOf="parent" android:layout_height="wrap_content"
app:layout_constraintStart_toStartOf="parent" android:fontFamily="sans-serif-black"
app:layout_constraintTop_toTopOf="parent" /> android:text="Création d'une annonce"
android:textAlignment="center"
android:textAppearance="@style/TextAppearance.AppCompat.Large"
android:textColor="@color/purple_500"
android:textSize="24sp" />
<Space
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:minHeight="@dimen/activity_vertical_margin" />
<ImageButton
android:id="@+id/imageButton"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:src="@drawable/ic_baseline_add_box_24" />
<Space
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:minHeight="@dimen/activity_vertical_margin" />
<TextView
android:id="@+id/labelTitre"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:alpha="100"
android:fontFamily="sans-serif-medium"
android:text="Titre de l'annonce :"
android:textAppearance="@style/TextAppearance.AppCompat.Medium" />
<EditText
android:id="@+id/titreAnnonce"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:ems="10"
android:hint="ex: Annonce test"
android:inputType="text"
android:textColorHint="#4D000000" />
<Space
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:minHeight="@dimen/activity_vertical_margin" />
<TextView
android:id="@+id/labelPrix"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:fontFamily="sans-serif-medium"
android:text="Prix :"
android:textAppearance="@style/TextAppearance.AppCompat.Medium" />
<EditText
android:id="@+id/prixAnnonce"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:ems="10"
android:hint="ex: 5.00€"
android:inputType="numberDecimal"
android:textColorHint="#4D000000" />
<Space
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:minHeight="@dimen/activity_vertical_margin" />
<TextView
android:id="@+id/labelAdresse"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:fontFamily="sans-serif-medium"
android:text="Adresse : "
android:textAppearance="@style/TextAppearance.AppCompat.Medium" />
<EditText
android:id="@+id/adresseAnnonce"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:ems="10"
android:hint="ex: Douai"
android:inputType="text"
android:textColorHint="#4D000000" />
<Space
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:minHeight="@dimen/activity_vertical_margin" />
<Button
android:id="@+id/boutonAjoutAnnonce"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:text="ajouter" />
</LinearLayout>
</androidx.constraintlayout.widget.ConstraintLayout> </androidx.constraintlayout.widget.ConstraintLayout>
\ No newline at end of file
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